Apktool
Apktool copied to clipboard
AAPT bug: enum/flag attr in a secondary framework
Information
- Apktool Version: 2.3.4, 2.4.0-SNAPSHOT
- Operating System: Linux, Windows
- APK From: Wrote the bug sample myself
Stacktrace/Logcat
$ java -jar apktool.jar b -f framework2 -o framework2.apk
I: Using Apktool 2.4.0-896569-SNAPSHOT
W: Could not find sources
I: Building resources...
I: Building apk file...
I: Built apk...
$ java -jar apktool.jar if framework2.apk -p framework
I: Framework installed to: framework/2.apk
$ java -jar apktool.jar b -f -p framework app -o app.apk
I: Using Apktool 2.4.0-896569-SNAPSHOT
W: Could not find sources
I: Building resources...
W: W/ResourceType(18083): DynamicRefTable(0x02): No mapping for build-time package ID 0x02.
W: W/ResourceType(18083): e[0x01] -> 0x01
W: W/ResourceType(18083): e[0x7f] -> 0x7f
W: E/ResourceType(18083): Failed resolving ResTable_map name at 116 with ident 0x02030000
W: warning: Package not found for resource #02010000
W: W/ResourceType(18083): No known package when getting value for resource number 0x01010000
W: W/ResourceType(18083): Invalid package identifier when getting bag for resource number 0x01010000
I: Building apk file...
I: Built apk...
Steps to Reproduce
This can only be reproduced by using an attr of "enum" or "flag" format that's defined in a secondary framework (forcedPackageId > 0x01) inside an app and then trying to recompile the app against the secondary framework.
- The error seems to disappear when forcedPackageId is set to '1' for the secondary framework.
- The error seems to disappear when the enum/flag valid value list is empty.
- This doesn't happen with any other format of attr (reference, string, integer, boolean, color, float, dimension, fraction).
Sample
This tiny zip is a super-minimalist way to reproduce the issue: https://www.mediafire.com/file/zri2n3nm30sqhq8/AaptAttrBug.zip/file
Thanks for the detailed investigation. Guess we have a low level issue in our forced packageId patch. We need to handle the mapping of the dynamic reference table.