APKEditor: Building back from decompilation to apk fails
1.APKEditor version: 1.2.0 2.apk file: Settings.apk
3.run: java -jar APKEditor.jar d -i Settings.apk
00.000 I: [DECOMPILE] Decompiling ...
Input: Settings.apk
Output: Settings_decompile_null
Type: json
Split: false
----------------------------
00.020 I: [DECOMPILE] Loading ...
00.579 I: [DECOMPILE] Initializing android framework ...
00.579 I: [DECOMPILE] Loading android framework for version: 33
00.614 I: [DECOMPILE] Initialized framework: android-33
00.614 I: [DECOMPILE] Decompiling to JSON ...
00.659 I: [DECOMPILE] [SANITIZE]: Sanitizing paths ...
00.663 [DECOMPILE] [SANITIZE]: REN: 'META-INF/external__kotlinx.coroutines__android_common__kotlinx_cor 00.663 [DECOMPILE] [SANITIZE]: REN: 'META-INF/packages__apps__MiuiSettingsLib__android_common__MiuiSettingsLib.kotlin_module' -> 'META-INF/alias_45341996'
00.667 I: [DECOMPILE] [SANITIZE]: DONE = 10572
03.648 I: [DECOMPILE] Dumping signatures ...
03.648 I: [DECOMPILE] Saved to: Settings_decompile_null
03.648 I: [DECOMPILE] Done
do not make any changes.
4.run: java -jar APKEditor.jar b -i Settings_decompile_null
00.000 I: [BUILD] Building ...
Input: Settings_decompile_null/base
Output: Settings_decompile_null_out.apk
----------------------------
00.019 I: [BUILD] Scanning JSON directory ...
00.103 I: [BUILD] Restoring file path ...
00.104 I: [BUILD] Building resources table: resources.arsc
Unexpected error:
java.io.IOException: resources.arsc: JSONObject["style"] not found.
java.lang.IllegalArgumentException: java.io.IOException: resources.arsc: JSONObject["style"] not found.
at com.reandroid.apk.ApkModule.getTableBlock(ApkModule.java:566)
at com.reandroid.apk.ApkModule.getTableBlock(ApkModule.java:573)
at com.reandroid.apk.ApkModule.listResFiles(ApkModule.java:398)
at com.reandroid.apk.ApkModule.listResFiles(ApkModule.java:394)
at com.reandroid.apk.PathMap.restore(PathMap.java:37)
at com.reandroid.apk.ApkJsonEncoder.restorePathMap(ApkJsonEncoder.java:82)
at com.reandroid.apk.ApkJsonEncoder.scanDirectory(ApkJsonEncoder.java:48)
at com.reandroid.apkeditor.compile.Builder.buildJson(Builder.java:69)
at com.reandroid.apkeditor.compile.Builder.run(Builder.java:49)
at com.reandroid.apkeditor.compile.Builder.execute(Builder.java:159)
at com.reandroid.apkeditor.Main.execute(Main.java:65)
at com.reandroid.apkeditor.Main.main(Main.java:38)
Caused by: java.io.IOException: resources.arsc: JSONObject["style"] not found.
at com.reandroid.apk.SingleJsonTableInputSource.getTableBlock(SingleJsonTableInputSource.java:68)
at com.reandroid.apk.ApkModule.loadTableBlock(ApkModule.java:652)
at com.reandroid.apk.ApkModule.getTableBlock(ApkModule.java:560)
... 11 more
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 50 (24 by maintainers)
Commits related to this issue
- [JSON] fix: convert only styled strings — committed to REAndroid/ARSCLib by REAndroid a year ago
- update ARSCLib for issue #20 — committed to REAndroid/APKEditor by REAndroid a year ago
- fix issue on attribute format encoding — committed to REAndroid/ARSCLib by REAndroid a year ago
- update-2 ARSCLib for issue #20 — committed to REAndroid/APKEditor by REAndroid a year ago
- fix dimension encode/decode error — committed to REAndroid/ARSCLib by REAndroid a year ago
- update-3 ARSCLib for issue #20 — committed to REAndroid/APKEditor by REAndroid a year ago
- fix: escaping xml characters — committed to REAndroid/ARSCLib by REAndroid a year ago
- update-4 ARSCLib for issue #20 — committed to REAndroid/APKEditor by REAndroid a year ago
- fix encode decode errors — committed to REAndroid/ARSCLib by REAndroid a year ago
- update-5 ARSCLib for issue #20 — committed to REAndroid/APKEditor by REAndroid a year ago
- encode arrays with name attribute — committed to REAndroid/ARSCLib by REAndroid a year ago
- update-6 ARSCLib for issue #20 — committed to REAndroid/APKEditor by REAndroid a year ago
- fix complex number decimal places — committed to REAndroid/ARSCLib by REAndroid a year ago
- fix color encoding — committed to REAndroid/ARSCLib by REAndroid a year ago
- fix encoding of array type bag entries — committed to REAndroid/ARSCLib by REAndroid a year ago
- fix ResConfig parse three digit region — committed to REAndroid/ARSCLib by REAndroid a year ago
- update-7 ARSCLib for issue #20 — committed to REAndroid/APKEditor by REAndroid a year ago
- fix styled string builder — committed to REAndroid/ARSCLib by REAndroid a year ago
- fix decode styled strings — committed to REAndroid/ARSCLib by REAndroid a year ago
- fix parse styled strings — committed to REAndroid/ARSCLib by REAndroid a year ago
Check the latest release : V1.2.1
I found issue on duplicate resource names, check this update APKEditor-1.2.0-UPDATE-04.jar
Good ! We have solved a lot of issue on the way. I will update repos with proper release and I will credit you for your contribution. Thank you!
No point closing this issue without finding out the exact problem. I am making new separate program to compare resources in detail. I will get back to you when it is done
After testing, both xml and json are working fine.
Thanks for your work.
DIMENSION:
1.0dpwithout any adjustment the result will be 0.999999dp, that is why I tried to round up digits with best result possible.180.0dpcan be encoded to integer46081or5898257if you decode this values the result is the same. So you might see different integer result on JSON but it is the same.STRING:
Yes I confirm, it will be fixed
I will fix this and other issues and get back to you
thanks for your work.
Is this problem happening on chinese (zh-rCN) language only ? If not please change it to english for better communication.
Here is my builds based on your original file, now tell me which one is working and which is not (sign it if required)
original>decompile to xml>compileSettings_decompile_xml_out.apkapk from 1>decompile to json>compileSettings_decompile_xml_out_decompile_json_out.apkHere I made a massive change you can test it with APKEditor-1.2.0-UPDATE-01.jar
This is the value_xml(com.android.settings) file of Settings
some of them don’t work
It’s possible that it has something to do with the frame. json can guarantee 100% correctness. If no progress is made, this issue can be closed first.
Thanks for your work.
Ohh I made silly mistake here. Check the latest update
I can’t figure out where exactly this problem is. I compared (using custom program byte level) files built with json & xml, most differences are irrelevant except config size 64(xml) & 48(json) and I doubt this fixes your issue.
I updated releases, you can test now and it will be better if you can get some stacktraces/logs
Seems to be fixed now, check updates
Fixed major issues and release updated, you can test it now
Fixed with this commit I will update releases latter after fixing other issues
Good question, Consider dex(dalvik) decompiling we can decompile/compile to
smaliorjavabut most of the times java gets errorARSCto/fromXMLis like convertingDEXto/fromJAVAARSCto/fromJSONis like convertingDEXto/fromSMALIDecompiling to XML is not 1:1 it is based on guess and assumptions e.g. you have a value
1234there is no direct way to tell for XML this isSTRINGorINTEGERorFLOATbut for JSON you simply specify it withvalue_type:"xxxx". XML by itself has its own limitation/weakness.This is the reason why i came up with idea of JSON format as an agent between low level byte code and humans to modify binary resources with 100% accuracy. If you check commits history I added XML support lately because most developers are used to XML and got confused with the new JSON.
I always recommend to use JSON format (if you are good at it) it is guaranteed to be 100% accurate.
Anyways we will keep improving XML conversion but there is no logical way to reach 100% error free.
The developer of this apk put those characters AndroidManifest.xml for some reason or mistake. Not the problem of the parser. Check
AndroidManifest.xml.jsonThe error was DIMESION value encode/decode. On this case raw value -47615 supposed to be decoded as -186.0dp. Now this issue seems to be fixed and check the latest update.
You are pointing out good issues, hope you will keep doing same. Thank You !
I conducted a test, resources.arsc is no longer wrong. but the UI layout is not correct, is there a problem with xml parsing? I used the recompiled apk (xml) to decompile to json format again, and found that it could not match the original apk decompiled json file in some places.
The left side uses the xml format and decompiles it into json again.(Settings_decompile_xml_out_decompile_json) Settinhs_test.zip example: base/res-json/res/drawable-sw600dp-v13/core_scan_gesture_broadside.xml.json

I thought I fixed this issue a while ago. Now I fixed the issue and updated all along with the release APKEditor-1.2.0.jar Your apk should work fine with this