[Android Software/Hacking General [Developers Only]] evildog1:
As I'm no longer modding, this thread will not be updated anymore. Please refer to apktool issues https://github.com/iBotPeaches/Apktool/issues?q=is:issue++ and discussions https://github.com/iBotPeaches/Apktool/discussions for latest infomation

Since many got apktool.jar errors and don't know how to search or solve themself, I decided to explain and provide solutions here with links to Github. I have a friend who sometime can help me with this.

I will do my best to get much info. Feel free to post your thoughts

Know your error:

There’s a wide range of error messages you may encounter when decompiling and compiling your app. Depending on the kind of error you encounter, apktool.jar will always display the error message. Spotting error messages is easy

For example this log:

I: Using Apktool 2.4.1
I: Smaling smali folder into classes.dex...
I: Smaling smali_classes2 folder into classes2.dex...
I: Building resources...
W: D:\xxx\AndroidManifest.xml:15: Tag <uses-permission> attribute name has invalid character ' '.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\evildog1\AppData\Local\Temp\brut_util_Jar_2200487015856364895.tmp, p, --forced-package-id, 127, --min-sdk-version, 19, --target-sdk-version, 28, --version-code, 19227, --version-name, 4.1.1, --no-version-vectors, -F, C:\Users\evildog1\AppData\Local\Temp\APKTOOL3877124333918122178.tmp, -e, C:\Users\evildog1\AppData\Local\Temp\APKTOOL2736431752124554942.tmp, -0, arsc, -I, C:\Users\evildog1\AppData\Local\apktool\framework\1.apk, -S, D:\xxx\res, -M, D:\xxx\AndroidManifest.xml]

If you think could not exec is your error, it's actually not, the real error is actually a 'warning'

W: D:\APK Easy Tool\1-Decompiled APKs\xxx\AndroidManifest.xml:15: Tag <uses-permission> attribute name has invalid character ' '

The good thing it tells you which line it occured AndroidManifest.xml:15:. it's line 15 in AndroidManifest.xml

This was caused by a space in a permission tag. Removing it will fix the compiling error

It's not always a simple fix. This always depending

Check the APK file:

Sometimes APK is obfuscated in many ways.

Open the APK using 7-zip and WinRar and see if the first classes.dex is smaller than 500 KB or way bigger than 10 MB. If so, it a sign it's encrypted. Decompiling and compiling the big dex file will result in a smaller size and it will fail to decrypt due to missing encrypted block

Decompile and check if smali files and codes are obfuscated. This is an example of Netflix app that is obfuscated

Don't ask me how to break protected APK, I'm not a reverser so I can't help you with it.

Troubleshooting:

Sometime those troubleshooting tricks helps fixing errors. Please try one or more of the following below

- If you are using any 3rd party GUI tools, please try the actual apktool.jar with CMD first

- Use latest version of apktool.jar: https://ibotpeaches.github.io/Apktool/ and test

- If you are using latest version, try use older version of apktool.jar. Sometimes it can mitigate the issue

- Clear framework apktool empty-framework-dir --force and decompile the APK again.

- Decompile APK with --only-main-classes (Only disasemble dex classes in root (classes[0-9].dex). Prevents disasemble dex from assets folder) (apktool 2.4.1 and up only)

- Decompile APK with --no-res if you are only editing Java (smali) (--no-res will prevent the decompile of resources. This keeps the resources.arsc intact without any decode.)

- Decompile APK with --no-src if you are only editing the resources (xml) (--no-src will prevent the disassembly of the dex file(s). This keeps the apk dex file(s) and simply moves it during build.)

- Compile with --use-aapt2 (Use the aapt2 binary instead of appt)