Fixed: Missing Attributes / namespace / Format etc.#4037
Fixed: Missing Attributes / namespace / Format etc.#4037TechnoIndian wants to merge 17 commits intoiBotPeaches:mainfrom
Conversation
|
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. |
|
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 |
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 First ChangeAdded prefix if type="attr" & name startwith a digit ( attr_id ) - commit - e3bfadd Second ChangeThe second change that needs to be made is that currently, if |
|
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? 🌚 |



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-SNAPSHOTAPK INFO ( OBFUSCATE )
PACKAGE NAME -
com.musixmatch.android.lyrify ( 8.1.4 )( Tested ✅ )ORPACKAGE NAME -
com.orange.mobinilandme( Tested ✅ )ORPACKAGE NAME -
com.kaliranaapp.edu( Tested ✅ )Successfully Decompile with some warning, But error in Recompile
Recompile
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
now another problem face
missing attribute name&namespace( app: )fixed namespace & missing attribute name commit - d70fc0d
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.xmlerror: expected enum but got (raw string) 2error: expected flags but got (raw string) 0x2fixed missing enum entries commit - 0eeac07
fixed missing flags entries commit - 9388aa6
ResolveRemoveTest if APK is OBF commit - bb16ca7
Now I'm getting
missing attributeswarning 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.Store Missing Attributes in BinaryXmlResourceParser.java - commit - a16375e
Store Missing Attributes in ResStyle.java - commit - b8b9202
Write Missing Attributes - commit - d4de353
Now it's APK Build Successfully
But styles.xml attributes unresolved reference problem ( return missing attribute body always
@null) so need modify ResReference.java for resolve attributes reference otherwise APK crashresolve attributes reference - commit - 2510aa5
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 )Successfully Decompile, But error in Recompile
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
Recompile Successful ✅