apktool build apk fails
Asked Answered
B

12

23

I am experiencing very annoying problems with the application apktool problem. I do not understand what i am doing wrong, or what the problem is. I tried this on debian , and on linux mint. I used different versions of apktool,

resulting in the same error:

I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, -F, /tmp/APKTOOL3630495287059303807.tmp, -I, /home/awesomename/apktool/framework/1.apk, -S, /home/awesomename/out/./res, -M, /home/awesomename/out/./AndroidManifest.xml]
    at brut.androlib.res.AndrolibResources.aaptPackage(Unknown Source)
    at brut.androlib.Androlib.buildResourcesFull(Unknown Source)
    at brut.androlib.Androlib.buildResources(Unknown Source)
    at brut.androlib.Androlib.build(Unknown Source)
    at brut.androlib.Androlib.build(Unknown Source)
    at brut.apktool.Main.cmdBuild(Unknown Source)
    at brut.apktool.Main.main(Unknown Source)
Caused by: brut.common.BrutException: could not exec command: [aapt, p, -F, /tmp/APKTOOL3630495287059303807.tmp, -I, /home/windows/apktool/framework/1.apk, -S, /home/windows/out/./res, -M, /home/windows/out/./AndroidManifest.xml]
    at brut.util.OS.exec(Unknown Source)
    ... 7 more
Caused by: java.io.IOException: Cannot run program "aapt": error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
    at java.lang.Runtime.exec(Runtime.java:617)
    at java.lang.Runtime.exec(Runtime.java:485)
    ... 8 more
Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
    at java.lang.ProcessImpl.start(ProcessImpl.java:130)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
    ... 10 more

It seems it can not use aapt , but i read about apktool. And it seems that aapt is build inside apktool , why is it not working ?

Brasserie answered 26/4, 2014 at 22:31 Comment(1)
See also apktool - How Fix brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = -1073741515) - Stack Overflow for a different cause of the same error message.Dahlia
C
59

It seems there's some problem in building the resources while recompiling the apk. what you can do is, when you decompile your apk use this command

apktool d -f -r apkfilename.apk

here -f is to replace previous decompiled apk's code and -r is to ignore the decompiling of resources.

this would prevent the resources from being decompiled and will simply copy the same resources when you recompile the apk.

Contradistinction answered 18/5, 2014 at 7:48 Comment(1)
Problem is, this would not let me see the values folders. Which is the only reason I'm decompiling the apk.Audsley
P
7

In case you've been using v1 and now upgraded to v2, try manually deleting the framework file.

On windows 8 it's normally at C:\Users\YourName\apktool\framework\1.apk.

The file should be regenerated once you try to build something.

Plumose answered 8/10, 2014 at 12:20 Comment(2)
On OS X (macOS) it is at /Users/<username>//Library/apktool/framework/1.apk.Matelda
On GNU/Linux it's at .local/share/apktool/framework/1.apk, although you can change it on any operating system with --frame-path <dir>. -- also instead of manually delete the file apktool empty-framework-dir should do the same thing.Dahlia
M
3

My problem was solved by deleting the \framework\1.apk, making a backup on the files I modified, ereasing the dir and decompiling the *.apk again, etc... (on linux, the path is home/[user]/apktool/...). After the update, apktool always loaded the old resource table. N

Missilery answered 7/1, 2015 at 12:3 Comment(0)
D
3

For me, I solved this problem by first clearing apktool's framework directory by typing in the terminal.

$ apktool empty-framework-dir

Afterwards I uninstalled apktool and related files by typing

$ sudo apt purge apktool

Then i went to https://bitbucket.org/iBotPeaches/apktool/downloads/ to get the latest jar file for apktool(apktool_2.5.0.jar as at the time of writing this).

On first run

$ java -jar apktool_2.5.0.jar b <MyAPP.apk> #Without ><

it works.

since I work with apktool most of the times I needed a situation where I can run apktool from anywhere so I gave the jar file execute permissions by typing

$ sudo chmod +x apktool_2.5.0.jar 

Afterwards I moved it /usr/bin/ by typing

$ sudo apktool_2.5.0.jar /usr/bin/
Dresser answered 14/3, 2021 at 22:54 Comment(1)
thank you so much !!!! i was gone crazy with that aap2_64 error !!!!Metagalaxy
M
1

Definitely seems like the aapt PATH problem I had awhile back. Have you added aapt to PATH? If you still have problems, I have made a good apk kit in bash to avoid all these dependency problems. It supports apktool, signapk, zipalign,adb, fastboot, and heimdall. Check it out. All you need is a current java install.

http://forum.xda-developers.com/android/development/toolkit-apk-munky-rench-t3026757/post58747626#post58747626

Marjoram answered 15/2, 2015 at 3:4 Comment(0)
N
1

There isn’t really enough information to give you a definite answer.

How ever you mentioned using different versions but the aapt issue was solved in version 2.4. Dependencies have been reduced to java version 1.8 or greater and the framework.

I use Debian and have the following:

  • Apktool 2.4
  • java version 11
  • Android framework

That’s all it took to get rid of the aapt path error.

The last error I came across was unrelated to aapt but was on the framework so I ran this command

apktool empty-framework-dir

And it solved it.

Notorious answered 14/5, 2019 at 0:38 Comment(0)
C
0

try to put the dir which include aapt file to your PATH. for example, export PATH=$PATH:./ ./apktool b

Cinchonism answered 27/9, 2014 at 6:48 Comment(0)
P
0

try to install ia32-libs and update latest version of apktool. (if possible restart)

apktool requires "ia32-libs" which is not available after Ubuntu 12.04. install ia32-libs

sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6

Download latest version of apktools.jar - https://bitbucket.org/iBotPeaches/apktool/downloads

apktool complete installation guide - http://ibotpeaches.github.io/Apktool/install/

Permission answered 25/5, 2016 at 20:47 Comment(0)
I
0

I just encounter same problem when run apktool d foo.apk(decompiled success) and then apktool b foo(recompile failed with similar error).

The apktool tool above was installed via sudo apt-get install apktool on Kali Linux.

So, the solution was visits apktool's official site, e.g. https://connortumbleson.com/2017/01/23/apktool-v2-2-2-released/ (it's latest version at this time of writing), download it, md5sum it, e.g. md5sum apktool_2.2.2.jar to verify, then rename that apktool_2.2.2.jar to apktool.jar.

Then do java -jar ./apktool.jar b foo to recompile, it success without error (the generated apk located at ./foo/dist/foo.apk).

Incorruptible answered 4/2, 2017 at 21:44 Comment(0)
R
0

The main issue is apktool version you need 2.4.0

You must manually install it from ibotpeaches git hub

here some good info

https://www.youtube.com/watch?v=kB6s10Uwpcs

and a automated script for kali https://github.com/catenatedgoose?tab=repositories

Resonant answered 21/4, 2019 at 5:18 Comment(0)
C
0

In my mind the problem is how you install apktool... I had the same problem and I did this and it worked very well: For installation you first have to remove any installed apktool by the command: sudo apt purge apktool Then you'll have to install apktool but in a different way. To continue save the link bellow as apktool in a directory. [https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool] Then open this link below and download the latest apktool.jar file: https://bitbucket.org/iBotPeaches/apktool/downloads/ Then rename the file as apktool.jar After that give both files the permission by the command:

Sudo chmod -x apktool.jar

And for the saved script:

Sudo chmod -x apktool

At the end copy both files in the directory:

/usr/local/bin

By the command:

Sudo cp apktool.jar /usr/local/bin

And the script file:

Sudo cp apktool /usr/local/bin

After that try running apktoolin the terminal.

Chervonets answered 31/7, 2022 at 9:49 Comment(0)
Q
-2

The solution is to include your apktool directory into your system PATH.

Queensland answered 28/10, 2014 at 11:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.