Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Use of external aapt for building apk #1774
I have apktool embedded in a Spring Boot executable jar so that some extra processing is done before apktool is called to rebuild an apk.
Sometimes apktool fails to use the internal aapt (still investigating) and falls back to using the external one (by setting "aapt" in the command array instead of absolute path to the temp file generated from the internal aapt). The external aapt however doesn't work. I tried various aapt binaries from different versions of built-tools but none worked.
I went through this thread #1520 and believe I'm getting the same error "First type is not attr!".
I understand the internal aapt is patched and would like some clarification on whether non-patched aapt is no longer supported? Or if this is a temporary fix. But either way, it could be helpful to mention this in the documentation regarding the use of --aapt option.
Non-patched app is supported, but you are working with an application built in aapt2 and attempting to build with aapt1 (external). That is the reason you are getting that "first type is not attr" issue. There is nothing apktool can do there with a non-patched aapt1 binary in the context of a decoded aapt2 application.
There is 1 solution. Take the patched aapt for your system and add it to the system PATH, so that executing "aapt" runs the prebuilt patched binary. That should resolve your issue.
I'll leave this open until I read the docs about that parameter and check if it needs some additional information.
Thanks for the explanation. The docs for --use-aapt2 seems wrong (https://ibotpeaches.github.io/Apktool/documentation/).
Does apktool choose the right version of aapt when rebuilding the apk (it doesn't look so in the source code and I see calls to aapt1Package in verbose mode)? Does this option need (have) to be used for both decoding and rebuilding of an apk that was built using aapt2? If I rebuild my apk (built by gradle plugin 3) without using external aapt, it works. But would you not recommend doing this?
In addition, "aapt2 version" gives a text slightly different prior to android sdk 26.0.2.
@iBotPeaches, I hope that the following is helpful for what you are looking for.