Skip to content

Comments

Fixed: Missing Attributes / namespace / Format etc.#4037

Closed
TechnoIndian wants to merge 17 commits intoiBotPeaches:mainfrom
TechnoIndian:main
Closed

Fixed: Missing Attributes / namespace / Format etc.#4037
TechnoIndian wants to merge 17 commits intoiBotPeaches:mainfrom
TechnoIndian:main

Conversation

@TechnoIndian
Copy link

Fixed: Missing Attributes / namespace / Format etc.

Info

OS: Termux ( Android )

used aapt2 Binary - https://github.com/Maximoff/binaries/blob/main/bin/arm64-v8a/sdk35/aapt2

aapt2 version: Android Asset Packaging Tool (aapt) 2.19-R.20584df_1 (build by tilks 20241028)

Apktool version: apktool-v2.12.1-33-0df4f393-SNAPSHOT

APK INFO ( OBFUSCATE )

PACKAGE NAME - com.musixmatch.android.lyrify ( 8.1.4 ) ( Tested ✅ )

OR

PACKAGE NAME - com.orange.mobinilandme ( Tested ✅ )

OR

PACKAGE NAME - com.kaliranaapp.edu ( Tested ✅ )

I: Using Apktool v2.12.1-33-0df4f393-SNAPSHOT on Musixmatch_8.1.4.apk with 8 threads
I: Copying raw classes.dex file...
I: Copying raw classes2.dex file...
I: Copying raw classes3.dex file...
I: Copying raw classes4.dex file...
I: Loading resource table...
I: Decoding file-resources...
I: Loading resource table from file: /data/data/com.termux/files/home/.local/share/apktool/framework/1.apk
I: Decoding values */* XMLs...
W: null style reference: key=ResReference{pkg=ResPackage{id=0x7f, name=com.musixmatch.android.lyrify}, id=0x7f04046d, name=null, type=RESOURCE}, value=ResReference{pkg=ResPackage{id=0x7f, name=com.musixmatch.android.lyrify}, id=0x7f14054f, name=null, type=RESOURCE}
W: null style reference: key=ResReference{pkg=ResPackage{id=0x7f, name=com.musixmatch.android.lyrify}, id=0x7f04046e, name=null, type=RESOURCE}, value=ResReference{pkg=ResPackage{id=0x7f, name=com.musixmatch.android.lyrify}, id=0x7f140551, name=null, type=RESOURCE}
W: null style reference: key=ResReference{pkg=ResPackage{id=0x7f, name=com.musixmatch.android.lyrify}, id=0x7f04046f, name=null, type=RESOURCE}, value=ResReference{pkg=ResPackage{id=0x7f, name=com.musixmatch.android.lyrify}, id=0x7f140552, name=null, type=RESOURCE}
W: null style reference: key=ResReference{pkg=ResPackage{id=0x7f, name=com.musixmatch.android.lyrify}, id=0x7f040470, name=null, type=RESOURCE}, value=ResReference{pkg=ResPackage{id=0x7f, name=com.musixmatch.android.lyrify}, id=0x7f140555, name=null, type=RESOURCE}
W: null style reference: key=ResReference{pkg=ResPackage{id=0x7f, name=com.musixmatch.android.lyrify}, id=0x7f040471, name=null, type=RESOURCE}, value=ResReference{pkg=ResPackage{id=0x7f, name=com.musixmatch.android.lyrify}, id=0x7f140554, name=null, type=RESOURCE}
W: null style reference: key=ResReference{pkg=ResPackage{id=0x7f, name=com.musixmatch.android.lyrify}, id=0x7f040474, name=null, type=RESOURCE}, value=ResReference{pkg=ResPackage{id=0x7f, name=com.musixmatch.android.lyrify}, id=0x7f140559, name=null, type=RESOURCE}
....
I: Decoding AndroidManifest.xml with resources...
I: Copying original files...
I: Copying assets...
I: Copying lib...
I: Copying unknown files...

Successfully Decompile with some warning, But error in Recompile

Recompile

~ $ java -jar apktool-v2.12.1-33-0df4f393-SNAPSHOT.jar b Musixmatch_8.1.4 --aapt ./aapt2
I: Using Apktool v2.12.1-33-0df4f393-SNAPSHOT on Musixmatch_8.1.4.apk with 8 threads
I: Checking whether resources have changed...
I: Building resources with aapt2...
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/anim/2130771980.xml:2: error: not well-formed (invalid token).
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/anim/2130771980.xml: error: file failed to compile.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/anim/2130772007.xml:2: error: not well-formed (invalid token).
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/anim/2130772007.xml: error: file failed to compile.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/anim/2130772027.xml:2: error: not well-formed (invalid token).
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/anim/2130772027.xml: error: file failed to compile.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/anim/2130772029.xml:2: error: not well-formed (invalid token).
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/anim/2130772029.xml: error: file failed to compile.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/anim/2130772031.xml:2: error: not well-formed (invalid token).
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/anim/2130772031.xml: error: file failed to compile.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/anim/2130772068.xml:2: error: not well-formed (invalid token).
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/anim/2130772068.xml: error: file failed to compile.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/animator/2130837504.xml:4: error: not well-formed (invalid token).
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/animator/2130837504.xml: error: file failed to compile.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/animator/2130837513.xml:4: error: not well-formed (invalid token).
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/animator/2130837513.xml: error: file failed to compile.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/animator/2130837516.xml:7: error: not well-formed (invalid token).
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/animator/2130837516.xml: error: file failed to compile.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/animator/2130837517.xml:7: error: not well-formed (invalid token).
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/animator/2130837517.xml: error: file failed to compile.
Exception in thread "main" brut.androlib.exceptions.AndrolibException: brut.common.BrutException: Execution failed (exit code = 1): [./aapt2, compile, --dir, /data/data/com.termux/files/home/Musixmatch_8.1.4/res, --legacy, -o, /data/data/com.termux/files/home/Musixmatch_8.1.4/build/resources.zip]
        at brut.androlib.res.AaptInvoker.invoke(SourceFile:89)
        at brut.androlib.ApkBuilder.buildResources(SourceFile:320)
        at brut.apktool.Main.main(SourceFile:95)
Caused by: brut.common.BrutException: Execution failed (exit code = 1): [./aapt2, compile, --dir, /data/data/com.termux/files/home/Musixmatch_8.1.4/res, --legacy, -o, /data/data/com.termux/files/home/Musixmatch_8.1.4/build/resources.zip]
        at brut.util.OS.exec(SourceFile:148)
        at brut.androlib.res.AaptInvoker.invoke(SourceFile:85)
        ... 2 more

IMG_20251205_121229

Conclusion

if OBF attribute is integer mean startwith digit then show error: not well-formed (invalid token). According to ChatGPT XML attribute names must not begin with a number (digit).

so now i'm fixed it - commit - e3bfadd

IMG_20251205_121321

now another problem face missing attribute name & namespace ( app: )

~ $ java -jar apktool-v2.12.1-35-e3bfadd8-SNAPSHOT.jar b Musixmatch_8.1.4 -f --aapt ./aapt2
I: Using Apktool v2.12.1-35-e3bfadd8-SNAPSHOT on Musixmatch_8.1.4.apk with 8 threads
I: Copying raw classes.dex file...
I: Copying raw classes2.dex file...
I: Copying raw classes3.dex file...
I: Copying raw classes4.dex file...
I: Building resources with aapt2...
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/drawable/2131231512.xml:6: error: not well-formed (invalid token).
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/drawable/2131231512.xml: error: file failed to compile.
Exception in thread "main" brut.androlib.exceptions.AndrolibException: brut.common.BrutException: Execution failed (exit code = 1): [./aapt2, compile, --dir, /data/data/com.termux/files/home/Musixmatch_8.1.4/res, --legacy, -o, /data/data/com.termux/files/home/Musixmatch_8.1.4/build/resources.zip]
        at brut.androlib.res.AaptInvoker.invoke(SourceFile:89)
        at brut.androlib.ApkBuilder.buildResources(SourceFile:320)
        at brut.apktool.Main.main(SourceFile:95)
Caused by: brut.common.BrutException: Execution failed (exit code = 1): [./aapt2, compile, --dir, /data/data/com.termux/files/home/Musixmatch_8.1.4/res, --legacy, -o, /data/data/com.termux/files/home/Musixmatch_8.1.4/build/resources.zip]
        at brut.util.OS.exec(SourceFile:148)
        at brut.androlib.res.AaptInvoker.invoke(SourceFile:85)
        ... 2 more

IMG_20251205_122134

fixed namespace & missing attribute name commit - d70fc0d

IMG_20251205_124606

Now another problem is missing enum / flags entries in attrs.xml

Bug - Certain enum / flags values used in styles.xml, don't have their define in attrs.xml

error: expected enum but got (raw string) 2

error: expected flags but got (raw string) 0x2

~ $ java -jar apktool-v2.12.1-36-d70fc0d7-SNAPSHOT.jar b Musixmatch_8.1.4 -f --aapt ./aapt2
I: Using Apktool v2.12.1-36-d70fc0d7-SNAPSHOT on Musixmatch_8.1.4.apk with 8 threads
I: Copying raw classes.dex file...
I: Copying raw classes2.dex file...
I: Copying raw classes3.dex file...
I: Copying raw classes4.dex file...
I: Building resources with aapt2...
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values/styles.xml:1738: error: expected enum but got (raw string) 2.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values/styles.xml:1925: error: expected enum but got (raw string) 1.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values/styles.xml:4783: error: expected enum but got (raw string) 0.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values/styles.xml:4785: error: expected enum but got (raw string) 1.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values-sw600dp/styles.xml:40: error: expected enum but got (raw string) 1.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values-sw600dp/styles.xml:41: error: expected enum but got (raw string) 1.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values-land/styles.xml:4: error: expected enum but got (raw string) 1.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values-land/styles.xml:5: error: expected enum but got (raw string) 1.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values/styles.xml:4832: error: expected enum but got (raw string) 0.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values/styles.xml:5291: error: expected flags but got (raw string) 0x2.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values/styles.xml:5614: error: expected enum but got (raw string) 3.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values/styles.xml:5651: error: expected enum but got (raw string) 3.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values/styles.xml:5718: error: expected enum but got (raw string) 0.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values/styles.xml:6174: error: expected enum but got (raw string) 1.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values/styles.xml:6186: error: expected enum but got (raw string) 3.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values/styles.xml:6197: error: expected enum but got (raw string) 3.
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/values/styles.xml:6269: error: expected flags but got (raw string) 0x2.
W: error: failed linking references.
Exception in thread "main" brut.androlib.exceptions.AndrolibException: brut.common.BrutException: Execution failed (exit code = 1): [./aapt2, link, -o, /data/data/com.termux/files/usr/tmp/APKTOOL6879133897840063135.tmp, --manifest, /data/data/com.termux/files/home/Musixmatch_8.1.4/AndroidManifest.xml, --min-sdk-version, 24, --target-sdk-version, 35, --version-code, 2025111102, --version-name, 8.1.4, --package-id, 127, --no-auto-version, --no-version-vectors, --no-version-transitions, --no-resource-deduping, --no-compile-sdk-metadata, --warn-manifest-validation, -I, /data/data/com.termux/files/home/.local/share/apktool/framework/1.apk, /data/data/com.termux/files/home/Musixmatch_8.1.4/build/resources.zip]
        at brut.androlib.res.AaptInvoker.invoke(SourceFile:192)
        at brut.androlib.ApkBuilder.buildResources(SourceFile:320)
        at brut.apktool.Main.main(SourceFile:95)
Caused by: brut.common.BrutException: Execution failed (exit code = 1): [./aapt2, link, -o, /data/data/com.termux/files/usr/tmp/APKTOOL6879133897840063135.tmp, --manifest, /data/data/com.termux/files/home/Musixmatch_8.1.4/AndroidManifest.xml, --min-sdk-version, 24, --target-sdk-version, 35, --version-code, 2025111102, --version-name, 8.1.4, --package-id, 127, --no-auto-version, --no-version-vectors, --no-version-transitions, --no-resource-deduping, --no-compile-sdk-metadata, --warn-manifest-validation, -I, /data/data/com.termux/files/home/.local/share/apktool/framework/1.apk, /data/data/com.termux/files/home/Musixmatch_8.1.4/build/resources.zip]
        at brut.util.OS.exec(SourceFile:148)
        at brut.androlib.res.AaptInvoker.invoke(SourceFile:188)
        ... 2 more

Screenshot_2025-12-05-12-52-46-51_5a36f6e0f8b96c8fbbd9efc54bb8de1e
IMG_20251205_130733

fixed missing enum entries commit - 0eeac07

fixed missing flags entries commit - 9388aa6

ResolveRemoveTest if APK is OBF commit - bb16ca7

IMG_20251205_191106
IMG_20251205_191050

Now I'm getting missing attributes warning entries because some attributes are not defined in attrs.xml, The reason is that certain obfuscated attributes are present in the XMLs resource files but are not added to resources.arsc.

During compilation, aapt2 checks every attribute and verifies whether it actually exists in the defined resources, so when it finds attributes in the XMLs files that are not declared in attrs.xml (or not present in resources.arsc after obfuscation), it throws these missing attributes' warnings.

When I was trying to find out where the MISSING_PREFIX attributes were being generated from, since their entries weren't in attrs.xml, I discovered that they were coming from BinaryXmlResourceParser.java and ResStyle.java.

Because the resource XMLs files are decompiled first, and attrs.xml is generated before styles.xml, instead of cross add entries, we will store these missing entries. Then, after the XMLs and resources are decompiled, we will add the missing entries to attrs.xml using a new method like "writeMissingATTR" so that the references can be verified during compilation.

~ $ java -jar apktool-v2.12.1-39-bb16ca72-SNAPSHOT.jar b Musixmatch_8.1.4 -f --aapt ./aapt2
I: Using Apktool v2.12.1-39-bb16ca72-SNAPSHOT on Musixmatch_8.1.4.apk with 8 threads
I: Copying raw classes.dex file...
I: Copying raw classes2.dex file...
I: Copying raw classes3.dex file...
I: Copying raw classes4.dex file...
I: Building resources with aapt2...
W: /data/data/com.termux/files/home/Musixmatch_8.1.4/res/drawable/2131231512.xml:6: error: attribute APKTOOL_MISSING_0x7f040679 (aka com.musixmatch.android.lyrify:APKTOOL_MISSING_0x7f040679) not found.
W: error: failed linking file resources.
Exception in thread "main" brut.androlib.exceptions.AndrolibException: brut.common.BrutException: Execution failed (exit code = 1): [./aapt2, link, -o, /data/data/com.termux/files/usr/tmp/APKTOOL15612545695950574344.tmp, --manifest, /data/data/com.termux/files/home/Musixmatch_8.1.4/AndroidManifest.xml, --min-sdk-version, 24, --target-sdk-version, 35, --version-code, 2025111102, --version-name, 8.1.4, --package-id, 127, --no-auto-version, --no-version-vectors, --no-version-transitions, --no-resource-deduping, --no-compile-sdk-metadata, --warn-manifest-validation, -I, /data/data/com.termux/files/home/.local/share/apktool/framework/1.apk, /data/data/com.termux/files/home/Musixmatch_8.1.4/build/resources.zip]
        at brut.androlib.res.AaptInvoker.invoke(SourceFile:192)
        at brut.androlib.ApkBuilder.buildResources(SourceFile:320)
        at brut.apktool.Main.main(SourceFile:95)
Caused by: brut.common.BrutException: Execution failed (exit code = 1): [./aapt2, link, -o, /data/data/com.termux/files/usr/tmp/APKTOOL15612545695950574344.tmp, --manifest, /data/data/com.termux/files/home/Musixmatch_8.1.4/AndroidManifest.xml, --min-sdk-version, 24, --target-sdk-version, 35, --version-code, 2025111102, --version-name, 8.1.4, --package-id, 127, --no-auto-version, --no-version-vectors, --no-version-transitions, --no-resource-deduping, --no-compile-sdk-metadata, --warn-manifest-validation, -I, /data/data/com.termux/files/home/.local/share/apktool/framework/1.apk, /data/data/com.termux/files/home/Musixmatch_8.1.4/build/resources.zip]
        at brut.util.OS.exec(SourceFile:148)
        at brut.androlib.res.AaptInvoker.invoke(SourceFile:188)
        ... 2 more

IMG_20251205_195521
IMG_20251205_195452

Store Missing Attributes in BinaryXmlResourceParser.java - commit - a16375e

Store Missing Attributes in ResStyle.java - commit - b8b9202

Write Missing Attributes - commit - d4de353

IMG_20251205_212221

Now it's APK Build Successfully

~ $ java -jar apktool-v2.12.1-42-d4de353d-SNAPSHOT.jar b Musixmatch_8.1.4 -f --aapt ./aapt2
I: Using Apktool v2.12.1-42-d4de353d-SNAPSHOT on Musixmatch_8.1.4.apk with 8 threads
I: Copying raw classes.dex file...
I: Copying raw classes2.dex file...
I: Copying raw classes3.dex file...
I: Copying raw classes4.dex file...
I: Building resources with aapt2...
I: Building apk file...
I: Importing assets...
I: Importing lib...
I: Importing unknown files...
I: Built apk into: Musixmatch_8.1.4/dist/Musixmatch_8.1.4.apk

IMG_20251205_212412

But styles.xml attributes unresolved reference problem ( return missing attribute body always @null ) so need modify ResReference.java for resolve attributes reference otherwise APK crash

resolve attributes reference - commit - 2510aa5

IMG_20251205_213947

now if apk resources is obfuscated the Apktool handle automatically


Note now we have write only the missing attributes, but also verifies the aapt2 format reference. If there is a format mismatch, it gives an aapt2 error. However, we can use more than one ResType in the format, like (format="color|reference|boolean"). Why don't we store all references as attributes, recognize them, and then add only the ResType in the format?

APK INFO

PACKAGE NAME - com.whatsapp ( 2.25.36.6 )


~ $ java -jar apktool-v2.12.1-45-6e34cbda-SNAPSHOT.jar d com.whatsapp.apk -f -s
I: Using Apktool v2.12.1-45-6e34cbda-SNAPSHOT on com.whatsapp.apk with 8 threads
I: Copying raw classes.dex file...
I: Copying raw classes2.dex file...
I: Copying raw classes3.dex file...
I: Copying raw classes4.dex file...
I: Copying raw classes5.dex file...
I: Copying raw classes6.dex file...
I: Copying raw classes7.dex file...
I: Copying raw classes8.dex file...
I: Copying raw classes9.dex file...
I: Loading resource table...
I: Decoding file-resources...
I: Loading resource table from file: /data/data/com.termux/files/home/.local/share/apktool/framework/1.apk
I: Decoding values */* XMLs...
I: Writing missing attributes into attrs.xml
I: Decoding AndroidManifest.xml with resources...
I: Copying original files...
I: Copying assets...
I: Copying lib...
I: Copying unknown files...

Successfully Decompile, But error in Recompile

~ $ java -jar apktool-v2.12.1-45-6e34cbda-SNAPSHOT.jar b com.whatsapp -f --aapt ./aapt2
I: Using Apktool v2.12.1-45-6e34cbda-SNAPSHOT on com.whatsapp.apk with 8 threads
I: Copying raw classes.dex file...
I: Copying raw classes2.dex file...
I: Copying raw classes3.dex file...
I: Copying raw classes4.dex file...
I: Copying raw classes5.dex file...
I: Copying raw classes6.dex file...
I: Copying raw classes7.dex file...
I: Copying raw classes8.dex file...
I: Copying raw classes9.dex file...
I: Building resources with aapt2...
W: /data/data/com.termux/files/home/com.whatsapp/res/drawable/mtrl_switch_thumb.xml:6: error: 'true' is incompatible with attribute attr_0x7f040ba2 (attr) color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e00bd.xml:14: error: '2' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e032f.xml:9: error: '0' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e03a8.xml:6: error: '1' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e03a9.xml:7: error: '0' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e03b4.xml:2: error: '1' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e045f.xml:5: error: '0' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e04b2.xml:13: error: '2' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e04cb.xml:10: error: '2' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e04e7.xml:8: error: '2' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e0565.xml:5: error: '1' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e0590.xml:5: error: '0' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e06df.xml:10: error: '1' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e0728.xml:9: error: '2' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e072a.xml:9: error: '2' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e078e.xml:7: error: '1' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e09c7.xml:13: error: '2' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e0b87.xml:19: error: '2' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e0bbc.xml:13: error: '2' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
W: /data/data/com.termux/files/home/com.whatsapp/res/layout/layout_0x7f0e0bef.xml:4: error: '1' is incompatible with attribute attr_0x7f04088c (attr) reference|color.
Exception in thread "main" brut.androlib.exceptions.AndrolibException: brut.common.BrutException: Execution failed (exit code = 1): [./aapt2, link, -o, /data/data/com.termux/files/usr/tmp/APKTOOL14181000638330671880.tmp, --manifest, /data/data/com.termux/files/home/com.whatsapp/AndroidManifest.xml, --min-sdk-version, 21, --target-sdk-version, 35, --version-code, 253606004, --version-name, 2.25.36.6, --package-id, 127, --no-auto-version, --no-version-vectors, --no-version-transitions, --no-resource-deduping, --no-compile-sdk-metadata, --warn-manifest-validation, -I, /data/data/com.termux/files/home/.local/share/apktool/framework/1.apk, /data/data/com.termux/files/home/com.whatsapp/build/resources.zip]
        at brut.androlib.res.AaptInvoker.invoke(SourceFile:192)
        at brut.androlib.ApkBuilder.buildResources(SourceFile:320)
        at brut.apktool.Main.main(SourceFile:95)
Caused by: brut.common.BrutException: Execution failed (exit code = 1): [./aapt2, link, -o, /data/data/com.termux/files/usr/tmp/APKTOOL14181000638330671880.tmp, --manifest, /data/data/com.termux/files/home/com.whatsapp/AndroidManifest.xml, --min-sdk-version, 21, --target-sdk-version, 35, --version-code, 253606004, --version-name, 2.25.36.6, --package-id, 127, --no-auto-version, --no-version-vectors, --no-version-transitions, --no-resource-deduping, --no-compile-sdk-metadata, --warn-manifest-validation, -I, /data/data/com.termux/files/home/.local/share/apktool/framework/1.apk, /data/data/com.termux/files/home/com.whatsapp/build/resources.zip]
        at brut.util.OS.exec(SourceFile:148)
        at brut.androlib.res.AaptInvoker.invoke(SourceFile:188)
        ... 2 more

IMG_20251205_220312
IMG_20251205_220440

Now, using a new method recognizeAttributeFormat, we will cross checking all the resource XMLs files attribute value's ResType after decompilation in attrs.xml to check if there are any different ResType. If there are, join into formats.

Store ResType - commit - f15c67a

write & join ResType into attrs.xml - commit - fd65b4c

IMG_20251205_223829

~ $ java -jar apktool-v2.12.1-45-fd65b4ce-SNAPSHOT.jar b com.whatsapp -f --aapt ./aapt2
I: Using Apktool v2.12.1-45-fd65b4ce-SNAPSHOT on com.whatsapp.apk with 8 threads
I: Copying raw classes.dex file...
I: Copying raw classes2.dex file...
I: Copying raw classes3.dex file...
I: Copying raw classes4.dex file...
I: Copying raw classes5.dex file...
I: Copying raw classes6.dex file...
I: Copying raw classes7.dex file...
I: Copying raw classes8.dex file...
I: Copying raw classes9.dex file...
I: Building resources with aapt2...
I: Building apk file...
I: Importing assets...
I: Importing lib...
I: Importing unknown files...
I: Built apk into: com.whatsapp/dist/com.whatsapp.apk

Recompile Successful ✅

@IgorEisberg
Copy link
Collaborator

Took me months to clean up the code to make some sense, this PR introduces a whole another mess and non-standard API for some specific obfuscated APKs. Can't stand behind that PR, and pretty sure so many changes are not necessary.
I keep a private Apktool build for my specific use case, I'd suggest you do the same instead of making a mess in the public build.
But, up to Connor.

@IgorEisberg
Copy link
Collaborator

IgorEisberg commented Dec 8, 2025

Regarding the "null style reference" warnings, it's normal and lets you know that some items are being omitted from style resources because they reference IDs that are missing in the ARSC. That means no ResEntrySpec at all - name, type, format(s) - are all missing. The only workaround for that is filling in missing attribute resources with new ResEntrySpec instances with a newly generated name and a generic default value without format or min/max specs (ResAttribute.DEFAULT). The problem is that it's only applicable for references to local attributes, you can't add ResEntrySpec for an ID that belongs to a different package (e.g. framework).

@TechnoIndian
Copy link
Author

Took me months to clean up the code to make some sense, this PR introduces a whole another mess and non-standard API for some specific obfuscated APKs. Can't stand behind that PR, and pretty sure so many changes are not necessary. I keep a private Apktool build for my specific use case, I'd suggest you do the same instead of making a mess in the public build. But, up to Connor.

Let's just ignore about this pull request 😂😂, It's so long because I wanted to apply it by default. There was another solution that would have exact same thing with just two minimal changes.

When we use the --res-resolve-mode dummy flag, we will need First commit. We will use this because aapt2 never accept attribute names that start with a digit.

IMG_20251205_121229

First Change

Added prefix if type="attr" & name startwith a digit ( attr_id ) - commit - e3bfadd

IMG_20251205_121321

Second Change

IMG_20251208_122615

The second change that needs to be made is that currently, if isDummy is true in Apktool, adds the line <item type="attr" name="APKTOOL_DUMMY_0x7f04000e">@null</item> to attrs.xml. However, this line is written incorrectly, which is causing the error: W: /data/data/com.termux/files/home/M/res/values/styles.xml:4: error: resource attr/APKTOOL_DUMMY_0x7f040010 (aka com.musixmatch.android.lyrify:attr/APKTOOL_DUMMY_0x7f040010) not found. As you can see in the screenshot, the APKTOOL_DUMMY_0x7f040010 attribute is defined in attrs.xml, but the error still shows because it's written in the wrong format. These lines should be written like this: <attr name="APKTOOL_DUMMY_0x7f04000f">@null</attr>

@iBotPeaches
Copy link
Owner

Could we split out the 2 changes into 2 different prs? I'd rather look at two tiny changes in different PRs than 19 file changes in this one.

thanks!

p.s if you are doing all of this on a mobile device - then kudos to you.

@TechnoIndian
Copy link
Author

TechnoIndian commented Dec 8, 2025

Could we split out the 2 changes into 2 different prs? I'd rather look at two tiny changes in different PRs than 19 file changes in this one.

thanks!

p.s if you are doing all of this on a mobile device - then kudos to you.

Okay brother, you can end this here. I will send another pull request.

Please tell me know if I should add Termux support to Apktool. Would you accept that? 🌚

@TechnoIndian TechnoIndian closed this by deleting the head repository Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants