Fix Apktool resource decoding bugs#17
Conversation
|
Error 1 fix was merged in Apktool, so catching this error might not be needed anymore. Maybe it's still relevant to match error patterns even though they're not supposed to appear ? |
|
@Sleeeee Can you maybe update the PR to just detect the errors in case they pop up again and link to your issue on apktool? |
|
The fixes for error 1 and error 3 have been merged but there was no new Apktool release since then (waiting for 3.0.3 or 3.1.0). Error 2 is still unfixed and there's no public issue that I know of. I may look into it when I have the right setup. For patch-apk, what I could do is tweak the code so that :
Sounds good ? If not, I can definitely just do step 1 and remove the aggressive fixes. |
|
Let me know what you think, it's ready on my end 😉 Refactored a tiny bit to make separate error handling and make the changes more readable. |
On obfuscated APKs, Apktool will struggle with resource decoding and throw different kinds of errors, which propagate to patch-apk when trying to rebuild an APK. We can catch the error logs and fix them programmatically, and re-run the build command.
Error 1 : namespacing error
See this issue for details about this error. Basically, it assigns the
android:namespace to properties that should be assignedapp:.From patch-apk, we can retrieve the filename and attribute that caused the error, then remove the
android:prefix.Error 2 : duplicate attributes
We can match duplicates inside their files with a regex and keep only one occurence.
Error 3 : incompatible flags
Enumerations with no actual value will be decoded as an invalid
0x0value. We can remove this attribute completely.Example output on a test app: