REAndroid / APKEditor

Powerful android apk editor - aapt/aapt2 independent
Apache License 2.0
647 stars 95 forks source link

APK rebuild error #35

Closed entwildfire closed 1 year ago

entwildfire commented 1 year ago

Hi. I am new to using this project. I tried to decompile an apk and then build exactly the same folder again.

decompile apk:

java -jar .\APKEditor-1.2.1.jar d -i '.\example.apk' -t xml -o .\decompile
00.000 I: [DECOMPILE] Decompiling ...
   Input: .\example.apk
 Output: .\decompile
 Type: xml
 ----------------------------
00.022 I: [DECOMPILE] Loading ...
00.200 I: [DECOMPILE] Initializing android framework ...
00.202 I: [DECOMPILE] Loading android framework for version: 27
00.253 I: [DECOMPILE] Initialized framework: android-27 (8.1.0)
00.254 I: [DECOMPILE] Decompiling to XML ...
00.270 I: [DECOMPILE] [SANITIZE]: Sanitizing paths ...
00.271 I: [DECOMPILE] [SANITIZE]: DONE = 752
00.272 I: [DECOMPILE] Decoding ...
00.273 I: [DECOMPILE] Validating resource names ...
00.337 I: [DECOMPILE] Decoding: AndroidManifest.xml
00.427 I: [DECOMPILE] Decoding public.xml: 0-comexample
00.447 I: [DECOMPILE] Decoding resource files ...
02.283 [DECOMPILE] Decoding: res\xml\global_tracker.xml
02.294 I: [DECOMPILE] Decoding values: 0-com.example
02.387 I: [DECOMPILE] Extracting root files
02.483 I: [DECOMPILE] Saved to: .\decompile
02.483 I: [DECOMPILE] Done

I tried to recompile some apk files, Most of them were success, But this specific apk failed with this error:

 java -jar .\APKEditor-1.2.1.jar b -i .\decompile -o .\recompile\example.recompile.apk
00.000 I: [BUILD] Building ...
   Input: .\decompile 
 Output: .\recompile\example.recompile.apk
 ----------------------------
00.022 I: [BUILD] Scanning XML directory ...
00.043 I: [BUILD] Scanning: decompile 
00.051 [BUILD] Searching public.xml: .\decompile 
00.081 I: [BUILD] Loading string pool ...
00.538 [BUILD] 3518 building pool: values-zu
00.654 I: [BUILD] Missing attribute: 'compileSdkVersion', skip loading frameworks
00.654 I: [BUILD] Set main package id from manifest: @drawable/icon
00.657 I: [BUILD] Main package id initialized: id = 0x7f, from: @drawable/icon
00.657 I: [BUILD] Encoding attrs ...
00.669 [BUILD] Encoding: values\attrs.xml
00.714 I: [BUILD] Encoding values ...
00.742 [BUILD] Encoding: values\styles.xml
ERROR:
Local entry not found: type=style, name=Theme.Light

The row that includes this style: <style name="CustomDialog" parent="@android:style/Theme.Light">

Note that the apk name and package id changed in the result.

REAndroid commented 1 year ago

The log already hinted you the cause

00.654 I: [BUILD] Missing attribute: 'compileSdkVersion', skip loading frameworks

Framework loader scans your manifest to decide which framework version to use, however I can tell from your log there is a tag <uses-sdk>.

For now use -framework-version 27

It will be fixed on next release

entwildfire commented 1 year ago

Thank you for answering. I pass the framework version as you said but the same error happened.

java -jar .\APKEditor-1.2.1.jar b -i .\decompile -o .\recompile\example.recompile.apk -framework-version 27
00.000 I: [BUILD] Building ...
   Input: .\decompile 
Output: .\recompile\example.recompile.apk
framework: 27
 ----------------------------
00.041 I: [BUILD] Scanning XML directory ...
00.062 I: [BUILD] Initializing preferred framework: 27
00.180 I: [BUILD] Initialized framework: 27
00.180 I: [BUILD] Scanning: decompile 
00.197 [BUILD] Searching public.xml: .\decompile 
00.275 I: [BUILD] Loading string pool ...
00.661 [BUILD] 3518 building pool: values-zu
00.739 I: [BUILD] Missing attribute: 'compileSdkVersion', skip loading frameworks
00.739 I: [BUILD] Set main package id from manifest: @drawable/icon
00.755 I: [BUILD] Main package id initialized: id = 0x7f, from: @drawable/icon
00.755 I: [BUILD] Encoding attrs ...
00.755 [BUILD] Encoding: values\attrs.xml
00.786 I: [BUILD] Encoding values ...
00.817 [BUILD] Encoding: values\styles.xml
ERROR:
Local entry not found: type=style, name=Theme.Light

Should I download this framework and place it somewhere? there is part of my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          android:versionCode="67"
          android:versionName="1.29"
          android:installLocation="auto"
          package="com.example"
          platformBuildVersionCode="27"
          platformBuildVersionName="8.1.0">
  <uses-sdk android:minSdkVersion="15"
            android:targetSdkVersion="15" />
...
REAndroid commented 1 year ago

Check the latest release V1.2.2