Apktool: Issue on Android R

Created on 29 Oct 2020  路  5Comments  路  Source: iBotPeaches/Apktool

Information

  1. Apktool Version (``) - 2.4.1
  2. Operating System (Mac, Linux, Windows) - Window 7 32bit
  3. APK From? (Playstore, ROM, Other) - ROM (Android R Beta Devce Samsung N20 ultra)

Stacktrace/Logcat

Targeting R+ (version 30 and above) requires the resources.arsc of installed APKs to be stored uncompressed and aligned on a 4-byte boundary

Include stacktrace here

No error building apk but App doesn't get registered to system , found some documentation
https://developer.android.com/about/versions/11/behavior-changes-11

Steps to Reproduce

  1. apktool

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG). Please attach framework files
(.apks that live in /system/framework or /system/priv-app)

APK

If this APK can be freely shared, please upload/attach a link to it.

Files.zip

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? - Yes
  2. If you are trying to install a modified apk, did you resign it? Yes
  3. Are you using the latest apktool version? Yes

Most helpful comment

just do zipalign -f -p 4 input.apk output.apk after you compile the apk.

All 5 comments

just do zipalign -f -p 4 input.apk output.apk after you compile the apk.

We have an existing ticket for R and zipaligning to align bytes is preferred.

Using zipalign does not help, since:
resources.arsc of installed APKs to be stored uncompressed AND aligned on a 4-byte boundary
But apktool builds a compressed apk, so it fails anyway.

EDIT: No, sorry.
The apk i was trying to decompile had a compressed resources.arsc , so apktool did not add "arsc" to the donotcompress section of apktool.yml. After editing, everything is fine. Maybe there is a change to make in the code: if the app targets r+, automatically add arsc to the donotcompress option.

Hi @ElDavoo
Could you please give more information on what you've edited? and how you fixed it?
I've just removed line - resources.arsc from apktool.yml and tried, but unfortunately, it's not working.

Thanks in advance!!

Hi,
The apk i've edited
Since it was not installing the error above, i wanted to use apktool to extract and recompress the apk, leaving resources.arsc uncompressed. However, since resources.arsc was compressed in the original apk, it was not automatically added to the doNotCompress option of apktool.yml . For this reason, when I recompressed the apk unzip and zipalign showed that the file was compressed. Adding "arsc" to the doNotCompress option of apktool.yml solved the problem because the apk was rebuild and resources.arsc was not compressed, allowing me to install the application (which crashes anyway but it's a problem of the app).For this reason, I propose that when the cmdline "-api 30" is written, apktool systematically adds resources.arsc to the doNotCompress option of apktool.yml. This way, the error will never appear.
Tell me if there is anything unclear.;
In short: apktool only behaves incorrectly only with apks that are already wrong.

Was this page helpful?
0 / 5 - 0 ratings