ApkTool Errors and How to Fix them

ApkTool Errors and How to Fix them

 

This tutorial I am writing today will help those who usually work with apktool to decompile, recompile apk files for reverse engineering purposes.

ApkTool is an advanced application that allows you to decompile an APK file, APK stands for  Android Application Package. The tool is widely used by millions of people to debug APK files and reverse engineer them as well. Over the years i have faced many errors while using ApkTool and today in this post I will mention some of the easy fixes of different errors that you may face while using ApkTool and a solution to fix them easily. So without wasting any more time, let’s get into the post.

Error: brut.common.BrutException: could not exec (exit code = 1)

You may get this error when you are trying to recompile your APK file.

Workout Around: Go to Framework on apkeasytool GUI version and then click on “Clear FW Cache” now try to recompile and it should work normally and if you are using terminal then run this command – ‘apktool empty-framework-dir

If the above solution does not work then try to recompile the APK file using aapt2 option

 

Error: Exception in thread Unsigned short value out of range: 65536

You may also get this error when recompiling your APK file, this error usually comes when you have edited the smali files and added some of your own stuff, for example, mod menu, or anything else that will exceed the method limit to more than 65K it will then throw an error.

Workaround: You will have to delete some useless smali junk folders or files that are not really needed, if you do not have knowledge of smali then try to delete specific folders that do not seem important then recompile the apk file and test the application if everything works then you are good to go.

 

Error: Exception in thread “main” org.jf.dexlib2.dexbacked.DexBackedDexFile$NotADexFile: Not a valid dex magic value: cf 77 4c c7 9b 21 01 cd or Class xxx has already been interned

This error usually occurs when there is a multidex apk or the dex files are encrypted by the developers.

Workaround: Make sure you are using the latest version of APKeasytool GUI version 2.4.1 and higher then go-to option and make sure that “only decompile on main classes in root (classes[0-9].dex)” is checked, see pic below

ApkTool Errors and How to Fix them

 

Error: Syntax errors

This usually happen too when you mess up something while editing the files.

Workaround: See where you messed up or delete and decompile the apk file again and start again.

Error: Error: String types not allowed

This usually happens when APKTOOL cannot decode certain things when decompiling the APK file, so it will create these dummy files instead that will throw an error later when recompiling it. There are many different kinds of error you can face because of these DUMMY files that are created

Workaround: You have to see where the error is directing you to which folder you will usually have APKTOOL_DUMMY etc something like that. Search for the term and deleted them from wherever it’s showing, usually, it will be inside assets folder XML files.

 

Error: No resource identifier found for attribute (Whatever it is)

Workaround: Open your AndroidManifest.xml and then look for this “android:manageSpace=”true” and then remove the line, then try to recompile and it should work fine.

 

Conclusion

These are the errors that I have faced so far and I have listed the solutions here, if I face any new errors then I will update this post with the updated error and solution too since I always try to fix the issue when I get it. If you found this useful then please share it with someone who may need this information too.

A programmer, gamer, and love researching new technology and games, reverse engineering applications. In my spare time, I usually play basketball or watch movies.