[UTIL][08.12.11] Apktool v1.4.3 - a tool for reverse engineering apk files

Status
Not open for further replies.
Search This thread
Jul 7, 2009
31
0
I can not use it, I qeusti errors, can you help?

Code:
fede@ChampionsLeague:~/Android/sdk/tools$ ./apktool my.apk  dir
Exception in thread "main" java.io.FileNotFoundException: /home/federico/Android/sdk/platforms/android-2.1/android.jar
        at brut.apktool.Main.getAndroidJarPath(Main.java:55)
        at brut.apktool.Main.main(Main.java:34)
 
Last edited:

olearyp

Senior Member
Sep 1, 2009
1,161
151
I can not use it, I qeusti errors, can you help?

Code:
fede@ChampionsLeague:~/Android/sdk/tools$ ./apktool my.apk  dir
Exception in thread "main" java.io.FileNotFoundException: /home/federico/Android/sdk/platforms/android-2.1/android.jar
        at brut.apktool.Main.getAndroidJarPath(Main.java:55)
        at brut.apktool.Main.main(Main.java:34)

You need to install the Android 2.1 platform (FileNotFoundException means that a file wasn't found, surprisingly). Follow the directions on http://developer.android.com/ for installing a platform.

You've also run the command incorrectly, forgetting the "d" argument, though maybe that changed. That's how it worked a couple days ago.
 

seaweeduk

Senior Member
Aug 19, 2009
316
4
Hi Brut.all

I was trying to change the DeskClock.apk included in the latest CM, when I try to run apktool b after making my changes I get the following error

Code:
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: Could not build apk for dir: /home/anthony/Desktop/DeskClockD/.
	at brut.androlib.Androlib.build(Androlib.java:65)
	at brut.apktool.Main.main(Main.java:42)
Caused by: brut.androlib.AndrolibException: Could not build apk for dir: /home/anthony/Desktop/DeskClockD/.
	at brut.androlib.ApkFile.build(ApkFile.java:135)
	at brut.androlib.ApkFile.build(ApkFile.java:96)
	at brut.androlib.Androlib.build(Androlib.java:60)
	... 1 more
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, -F, /home/anthony/Desktop/DeskClockD/build/tmp.apk, -I, /home/anthony/android-sdk-linux_86/platforms/android-2.1/android.jar, -M, /h
ome/anthony/Desktop/DeskClockD/./AndroidManifest.xml, -S, /home/anthony/Desktop/DeskClockD/./res]
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:131)
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:100)
	at brut.androlib.ApkFile.build(ApkFile.java:103)
	... 3 more
Caused by: brut.common.BrutException: could not exec command: [aapt, p, -F, /home/anthony/Desktop/DeskClockD/build/tmp.apk, -I, /home/anthony/android-sdk-linux_86/platforms/android-2.1/android.jar, -M, /home/anthony/Desktop/DeskClockD/./
AndroidManifest.xml, -S, /home/anthony/Desktop/DeskClockD/./res]
	at brut.util.OS.exec(OS.java:52)
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:129)
	... 5 more

any ideas? I have aapt install and in the path directory...
 

Brut.all

Inactive Recognized Developer
Jul 27, 2009
1,471
353
I was trying to change the DeskClock.apk included in the latest CM, when I try to run apktool b after making my changes I get the following error

It is one of the "weird" apps:

Code:
res/layout/alarm_alert.xml:6: error: Error: Resource is not public. (at 'src' with value '@android:drawable/call_contact').

android.R.drawable.call_contact should not be accessible for apps, but it is somehow referenced from DeskClock.apk . I have even seen apps referencing to non existent resources :-/

I think Google and manufacturers have some private tools for building apps. We need to write our own aapt tool to support some of the system apps.
 

seaweeduk

Senior Member
Aug 19, 2009
316
4
It is one of the "weird" apps:

Code:
res/layout/alarm_alert.xml:6: error: Error: Resource is not public. (at 'src' with value '@android:drawable/call_contact').

android.R.drawable.call_contact should not be accessible for apps, but it is somehow referenced from DeskClock.apk . I have even seen apps referencing to non existent resources :-/

I think Google and manufacturers have some private tools for building apps. We need to write our own aapt tool to support some of the system apps.

Ah yeah I figured as much after reading your response earlier. I'll stick with swapping the png's thanks for the excellent tool anyway, and thanks again for your work on maps :)
 

Brut.all

Inactive Recognized Developer
Jul 27, 2009
1,471
353
Some AOSP bits + my mods to not compile 4000 files for just a subset of features (Android sources are all-includes-all type) + JNI interface. I will upload it here in a while.

Is's messed up a bit - I don't like C++, so it's enough for me, that it works ;-)
 

Attachments

  • brut.androlib.jni.zip
    183.2 KB · Views: 419
  • Like
Reactions: haoyangw

Brut.all

Inactive Recognized Developer
Jul 27, 2009
1,471
353
@seaweeduk
I've modified android.jar file to make these resources public and now I am able to rebuilt working DeskClock.apk :) If you don't want to replace file in SDK, you may just create new dir with ./platforms/android-2.1/android.jar in it. I'm also attaching newer apktool, which you will probably need to build that app.
 

Attachments

  • desk.zip
    5.2 MB · Views: 333

BolecDST

Senior Member
May 4, 2009
294
38
Dublin
Will this work under ubuntu livecd? And is there a possibility to create something like this for windows users (sometime in future ofcourse). Thanks in advance for the answers.
 

myn

Retired Senior Recognized Developer
Nov 15, 2007
2,679
3,985
Running apktool-0.9.1 on Ubuntu I am getting the following error message:


Code:
root@ubuntu:/storage/Downloads/apktool-0.9.1# ./apktool 
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
	at brut.apktool.Main.main(Main.java:32)
 

olearyp

Senior Member
Sep 1, 2009
1,161
151
Running apktool-0.9.1 on Ubuntu I am getting the following error message:


Code:
root@ubuntu:/storage/Downloads/apktool-0.9.1# ./apktool 
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
	at brut.apktool.Main.main(Main.java:32)

You have to supply command line arguments (though that exception should probably be caught and usage text displayed.)

ALSO, OFF-TOPIC: Why are you logged in as root on an Ubuntu machine? Especially if you're trying to run apktool, which has no privilege escalation requirement?
 

zer0day

Senior Member
Oct 29, 2007
234
14
Running apktool-0.9.1 on Ubuntu I am getting the following error message:


Code:
root@ubuntu:/storage/Downloads/apktool-0.9.1# ./apktool 
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
	at brut.apktool.Main.main(Main.java:32)

You need to provide some arguments to the tool, see the project home page for example.
 

myn

Retired Senior Recognized Developer
Nov 15, 2007
2,679
3,985
You have to supply command line arguments (though that exception should probably be caught and usage text displayed.)

ALSO, OFF-TOPIC: Why are you logged in as root on an Ubuntu machine? Especially if you're trying to run apktool, which has no privilege escalation requirement?

Thanks. I thought it may be the lack of bounds checking.

Regarding root. I am running in a virtualized environment.
 

seaweeduk

Senior Member
Aug 19, 2009
316
4
@seaweeduk
I've modified android.jar file to make these resources public and now I am able to rebuilt working DeskClock.apk :) If you don't want to replace file in SDK, you may just create new dir with ./platforms/android-2.1/android.jar in it. I'm also attaching newer apktool, which you will probably need to build that app.

You absolute legend! Thanks so much works great :D :D
 
Last edited:

seaweeduk

Senior Member
Aug 19, 2009
316
4
Here's the modded deskclock (was only the widget I wanted to make changes to) and a screenshot in case any one was interested



Remove the old deskclock.apk from /system/app and install the attached replacement if you want it
 

Attachments

  • DeskClock.apk
    364.8 KB · Views: 89
Last edited:
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 95
    Brut.all said:
    It is a tool for reengineering 3rd party, closed, binary Android apps. It can decode resources to nearly original form and rebuild them after making some modifications; it makes possible to debug smali code step by step. Also it makes working with app easier because of project-like files structure and automation of some repetitive tasks like building apk, etc.

    It is NOT intended for piracy and other non-legal uses. It could be used for localizing, adding some features or support for custom platforms and other GOOD purposes. Just try to be fair with authors of an app, that you use and probably like.

    Features:

    • decoding resources to nearly original form
    • smali debugging: SmaliDebugging
    • helping with some repetitive tasks

    http://code.google.com/p/android-apktool/
    6
    Forget that Maven crap. It builds fine here. I'll just release the binary for v1.4.5. v1.4.6 is in testing and just isn't ready for the public.

    http://connortumbleson.com/apktool-v1-4-5-a-tool-for-reverse-engineering-apk-files/

    You may find the updated apktool above. It will work with ICS very well. Credits to JesusFreke and others involved in baksmali/smali as well as brut.all for the original apktool.

    Bugs here: https://github.com/iBotPeaches/brut.apktool/issues?state=open
    Updates here: http://connortumbleson.com/apktool-v1-4-5-a-tool-for-reverse-engineering-apk-files/

    Thanks,
    iBotPeaches
    6
    I'm going to make a new topic, so we don't have to post in a Legacy forum. I need to get off work and run all my last minute tests to be sure my final changes didn't break anything.

    Then I'll release. I will put a link to the new thread (when posted) here.
    5
    I've been busy. Its no easy task working with this application. I spend most my time setting breakpoints and just figuring out how the application works.

    I've been making my own whitepapers just so I can figure out how to read the data, because I can simply read the code and understand that is skips the first 4 bytes, but by re-doing the resource side of things and understanding for myself why bytes are skipped and why things are read helps me fix it.

    I don't wanna say I'll have it out by x time. I do this stuff in my free time. The positional error due to the formatted="false" is fixed in v1.4.6.