yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] Fraqq:
hey can someone help me? i already read most of the threat and the command in the console but i dont understand the command how to decompile and compile an .apk:confused::confused:

can someone write me the command?

Thanks
[G1 Android Development] capychimp:
apktool d apkfilename (remember the .apk and case sensitive) foldername (where you want it decomplied

ex: apktool d Phone.apk Phone

build again:

apktool b Phone
[G1 Android Development] Fraqq:
aahh now i understand the commands and the letters in []:D:D

THX
[G1 Android Development] Roladriz:
Hello everyone, I'm new to theming and have wrapped my head around the jist..I want to go further than Compiling images using Eclipse and my mentor pointed me to this tool for the decompiling of .apks. Does the Zip folder get extracted to \android-sdk-windows\tools?
[G1 Android Development] capychimp:
hey brut, your still on this or the maps are number 1 at the moment? :)
[G1 Android Development] Brut.all:
AFAIR I told you that I'm working on GM now :-) GM users had to wait 3 months, when I was working on apktool ;-)
[G1 Android Development] capychimp:
ahh ok sorry didn't catch that :) only fair i agree :)
[G1 Android Development] canadiancow:
But Maps users are pretty satisfied :p

And apktool improvements can help make Maps modifications easier :)
[G1 Android Development] Roladriz:
I have been trying to get this tool to work for some time and cant get it to let me run the decompile and build commands. I have tried unpacking it to my desktop, C:, and my last attempt was the sdk-windows\tools. I would really appreciate some advice please.
[G1 Android Development] olearyp:
While I hate to be an ass, did you actually read and try to understand the error message, which clearly and succinctly explains the disconnect?

Hint: Read the error message, then open apktool.bat in a text editor. Compare. From here there a couple of different ways to fix it, but you should be able to figure them out.
[G1 Android Development] CarbonKang:
Can anyone teach me how to get this set up. I just want to change text for the vanilla lockscreen. "unlock" "sound off" "sound on"
[G1 Android Development] Roladriz:
I don't look at your reply to my question as you being an ass. I understand the frustration that you feel when you see new people not understanding something that probably comes as second nature to you and yours alike. I actually appreciate the reply and therefore am forced to ask another question because I'm still not being granted access. I have extracted the apktool-install-windows zip, as well as the tar.bz2. I then opened the tar file and placed the apktool.jar file as well as these three files aapt, apktool.bat, mgwz.dll in C:\WINDOWS.(thanks adrynalyne) I open the cmd.exe and cd to C:\WINDOWS and type apktool and I get unable to access jarfile C:\WINDOWS. Same message appears when I try and run it as apktool.bat. Please, tell me that I am close and don't think that I am not trying my hardest to understand something that I am new to. Thanks olearyp
[G1 Android Development] Brut.all:
Hmm.. that's weird :-/ Did you rechecked three times that all these files are directly in WINDOWS directory? :-) What if you cd to C:\WINDOWS and run: 'java -jar apktool.jar' ?
[G1 Android Development] Roladriz:
Ok, Running that command gave me a different outcome, however I am unable to decompile the .apk. Does my d command look correct? Maybe I will read through this thread again to see if I missed something. I don't understand if the .apk gets decompiled from the phone while in debugging mode, or straight from the desktop.

C:\WINDOWS>java -jar apktool.jar d GenieWidget.apk GenieWidget.apk-decoded

I: Baksmaling...

Exception in thread "main" java.lang.RuntimeException: GenieWidget.apk: file not found

at org.jf.dexlib.Util.FileUtils.readFile(Unknown Source)

at org.jf.dexlib.DexFile.<init>(Unknown Source)

at org.jf.dexlib.DexFile.<init>(Unknown Source)

at brut.androlib.src.SmaliDecoder.decode(Unknown Source)

at brut.androlib.src.SmaliDecoder.decode(Unknown Source)

at brut.androlib.Androlib.decodeSourcesSmali(Unknown Source)

at brut.androlib.ApkDecoder.decode(Unknown Source)

at brut.apktool.Main.cmdDecode(Unknown Source)

at brut.apktool.Main.main(Unknown Source)
[G1 Android Development] Roladriz:
UPDATE: SUCCESS!!!! I want to thank you guys for helping me with this. I feel retarded because I have been messing with this for so long, but I refuse to give up. I knew I was close after the commands you gave me Brut.all. The problem was I didn't have the .apk in C:\WINDOWS...I know ...I know...n00b!!! After running the apk through the signing process I still can't get it to install on my phone but that in itself is another thread;)...Thanks again olearyp and Brut.all.

UPDATE:2 Found the out apk file in Dist. renamed to GenieWidget, signed, sealed, delivered.

Thank You bgill55 for this hint and so much more.

C:\WINDOWS>java -jar apktool.jar d GenieWidget.apk GenieWidget.apk-decoded

I: Baksmaling...

I: Decoding resource table...

I: Decoding resources...

I: Copying assets and libs...

make edit here

C:\WINDOWS>java -jar apktool.jar b GenieWidget.apk-decoded

I: Checking whether sources has changed...

I: Smaling...

I: Checking whether resources has changed...

I: Building resources...

I: Building apk file...
[G1 Android Development] tolovaj:
Hi Brut.all, I have a question;

in video "Apktool Demo 2 - Smali improvements" you "decompile" apk file using parameter "dj" and you get the src directory.

Using latest apktool, I there is no 'j' parameter and I also only get res and smali directories and no src directory.. The point is that I'm more keen on java than smali-type of code and I'd really love to have at least partial java decompiler :D

Is there anything I'm missing, or is this yet-to-come option?
[G1 Android Development] Brut.all:
Yet-to-come.

You could see on this video, that it isn't actually Java decoding. It creates Java interface, but whole code is still in smali - you can't run from smali ;-)
[G1 Android Development] ErickPetru:
Dozens of congratulations, Brut.all. HelixLauncher2 is very better on my native language. :p

Then I moved myself to use apktool with Beautiful Widgets.

But wasn't possible. Here are the errors:

C:\>apktool d "C:\Android\BeautifulWidgets2.0.1.apk" "C:\Android\decompiled\BeautifulWidgets"
I: Baksmaling...
I: Decoding resource table...
I: Decoding resources...
Exception in thread "main" brut.androlib.AndrolibException: Could not decode file "drawable/am.png" to "drawable/am.png"
at brut.androlib.res.decoder.ResFileDecoder.decode(Unknown Source)
at brut.androlib.res.decoder.ResFileDecoder.decode(Unknown Source)
at brut.androlib.res.AndrolibResources.decodeFile(Unknown Source)
at brut.androlib.res.AndrolibResources.decode(Unknown Source)
at brut.androlib.Androlib.decodeResourcesFull(Unknown Source)
at brut.androlib.ApkDecoder.decode(Unknown Source)
at brut.apktool.Main.cmdDecode(Unknown Source)
at brut.apktool.Main.main(Unknown Source)
Caused by: brut.androlib.AndrolibException: Could not decode raw stream
at brut.androlib.res.decoder.ResRawStreamDecoder.decode(Unknown Source)
at brut.androlib.res.decoder.ResStreamDecoderContainer.decode(Unknown Source)
... 8 more
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
at java.util.zip.ZipFile.read(Native Method)
at java.util.zip.ZipFile.access$1200(Unknown Source)
at java.util.zip.ZipFile$ZipFileInputStream.read(Unknown Source)
at java.io.InputStream.read(Unknown Source)
at org.apache.commons.io.IOUtils.copyLarge(Unknown Source)
at org.apache.commons.io.IOUtils.copy(Unknown Source)
... 10 more

I'm doing something wrong or this file can't be extracted?
[G1 Android Development] Brut.all:
Oo, something new! :-D

Could you successfully unpack this file using e.g. WinRAR? Is drawable/am.png file there and is it viewable? If double yes, then try to compress it again to zip file and use apktool on that new file.
[G1 Android Development] ErickPetru:
Thanks, worked.

Details:

While extracting with Winrar, an error happened (file corrupted).

But all was extracted. Then I was able to use apktool.

After recompiling, the generated apk is runing well.

...

I would take the matter of customizing Beautiful Widgets with an absurd question: is there any converter from Smali to Java?

No need to be a perfect converter where you can decompile, recompile and all remains working. But something that makes the Smali code more readable for a Java programmer, as a basis to implement new codes more easily. There is something anywhere?
[G1 Android Development] rac2030:
http://xdaforums.com/showthread.php?p=6525677
[G1 Android Development] Brut.all:
You have luck that rac2030 commented this part of your post - you have added this after I read your post, so I didn't see it.

And I don't think you want something like "-dj" option, linked by rac2030 above. But there is something useful for you:

http://code.google.com/p/dex2jar/

This is a tool for converting Dalvik Bytecode to regular Java bytecode. Then you could use some Java decompiler, I recommend JD-gui and you will get real Java sources of dex file. Of course this isn't perfect, but works quite well and both tools are still being developed :-)

There is also undx tool, alternative to dex2jar, but I don't like it.
[G1 Android Development] ErickPetru:
Yes, thanks rac2030 and Brut. :D

And I'll take a look at dex2jar (is that chinese?!). Many thanks.

So... I was trying apktool with the really new LauncherPro 0.2.0 Beta.

And nice errors:

C:\Users\Erick>apktool d "C:\Android\backup\com.fede.LauncherPro-0.2.0.apk" "C:\Android\decompiled\LauncherPro"
I: Baksmaling...
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: java.io.FileNotFoundException: C:\Android\decompiled\LauncherPro" \smali\com\fede\launcher\AddAdapter$ListItem.smali (A sintaxe do nome do arquivo, do nome do diretório ou do rótulo do volume está incorreta)
at brut.androlib.Androlib.decodeSourcesSmali(Unknown Source)
at brut.androlib.ApkDecoder.decode(Unknown Source)
at brut.apktool.Main.cmdDecode(Unknown Source)
at brut.apktool.Main.main(Unknown Source)
Caused by: brut.androlib.AndrolibException: java.io.FileNotFoundException: C:\Android\decompiled\LauncherPro" \smali\com\fede\launcher\AddAdapter$ListItem.smali (A sintaxe do nome do arquivo, do nome do diretório ou do rótulo do volume está incorreta)
at brut.androlib.src.SmaliDecoder.decode(Unknown Source)
at brut.androlib.src.SmaliDecoder.decode(Unknown Source)
... 4 more
Caused by: java.io.FileNotFoundException: C:\Android\decompiled\LauncherPro" \smali\com\fede\launcher\AddAdapter$ListItem.smali (A sintaxe do nome do arquivo, do nome do diretório ou do rótulo do volume está incorreta)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at brut.androlib.src.SmaliDecoder.decodeClassDefItem(Unknown Source)
... 6 more
C:\Users\Erick>

What could it be?

PS.: "A sintaxe do nome do arquivo, do nome do diretório ou do rótulo do volume está incorreta" = "The syntax of the file name, directory name or volume label is incorrect"

Edit:

Unziped, reziped and worked...
[G1 Android Development] aupeters:
Soo I tried installing/running this on my mac - unzipped the 2 files, put the contents (3 items) into /usr/local/bin, typed "apktool" into Terminal and that worked - gave me the directions.

Then I tried to decode an .apk and after a few moments hesitation says ".apk not found". I go and look at the directory (was on my desktop) and my whole desktop was gone. Like erased-gone. Even took my SDK which was on there.

Any idea if I did something wrong here?
[G1 Android Development] Brut.all:
:-/ I guess you have set your desktop as destination directory - apktool deletes destdir before decoding and it won't warn you about that, won't require --force switch or something like that. I was considering adding such switch, but concluded for most people it would be annoying.

But you aren't first ;-) Some people on http://www.entourageedge.com/forums/ have found my tool, someone lost one of his directory and then everyone were afraid to use it, so they were asking more experienced users to decode something for them ;-D

Maybe I should reconsider adding --force switch.
[G1 Android Development] olearyp:
At least a warning and an opportunity to bail out if the directory is nonempty is a good idea.
[G1 Android Development] rac2030:
I think that would be a good way, if the dir is not empty it would need the force switch to execute.

And this one as default if no force switch is given, display a warning and ask user for yes or no.
[G1 Android Development] hawst:
I'm using latest Sprint ROM 2.27.651.5 ported to GSM Hero. All goes fine. I'm trying to repack all .apks to add localization, but faced an issue, can you please help ?

For example, i will explain on Phone.apk, just unpack & pack it back.

- command to unpack (result is attached as 'Phone_unpack.txt'

apktool.bat -v d -s Phone.apk Phone

- command to pack (result is attached as 'Phone_pack.txt'

apktool.bat -v b Phone

As i see error cause is that apktool can't find some resources, so it placed plain ID to .xml file. Of coz it can't build it back coz no such resource.
[G1 Android Development] Lieu10ant:
anyone willing to edit Shazam to include a search intent to iMusicTao if it's installed on the phone (along side the amazon search)
[G1 Android Development] Brut.all:
You could try to:

Pull com.htc.resources.apk file from your device. Should be in /system/framework/ or /data/system-framework/ dir.

Unpack resources.arsc file from it.

Run "apktool publicize-resources resources.arsc" on it.

Zip only this one file to com.htc.resources.apk archive.

Unpack apktool.jar .

Replace brut/androlib/com.htc.resources.apk file with one you've just created.

Pack back to apktool.jar and use it.

Let me know, whether this worked for you :-)

I must add some automation to apktool - I can't keep HTC resources up to date all the time. Actually... I shouldn't redistribute them at all, because they are proprietary bits...

I think about something like: when you install apktool or want to use it against apks from new device, you must pull resources file from it (or maybe just connect through USB and apktool will pull it automatically), run "apktool add-framework-res file-res.apk" and apktool will do above steps, then save resulting apk somewhere in home dir for future use. It would be really nice feature.
[G1 Android Development] stari4ek:
Such a usefull information. If you didn't write it here, there is no way to find out these tidbits. Do you have plans to add it to faq/wiki?

Thank you for information, thank you for this great tool.
[G1 Android Development] Brut.all:
If hawst confirm that above instructions work for him, I will create enhancement task in issue tracker and add them there. I don't want to add them to wiki, because this is workaround which should be automatized and it will probably be in nearest future :-)
[G1 Android Development] hawst:
Thanks you very much ;). It works now for Phone, HtcContacts & HtcDialer .apks at least.
[G1 Android Development] hawst:
Now i'm faced another issue with WorldClock.apk

It is successfully unpacked, but can't be packed bak (WorldClock_pack.txt)

As i see apktool somehow unpacked res/amin/undim.html - binary file, of coz apktool can't build it back... Also tried on another rom - same error.

brut.zip contains updated res files to change in apktool.jar as u desribed.
[G1 Android Development] Brut.all:
http://code.google.com/p/android-apktool/issues/detail?id=34#c2

I must reserve some time for apktool - there are quite many things to do :-)
[G1 Android Development] :
This is awesome, thank you so much. Got me up and running again. :D
[G1 Android Development] Brut.all:
You didn't post about your problems earlier :-)

There are always many workarounds and mystical knowledge around such projects, it isn't possible to write them all in Wiki, etc. This is why IRC/forum is so useful :-)

If one of issues in project tracker is from you, then... yeah, I must update/fix them ;-)
[G1 Android Development] :
I've been too busy with work to start digging into this. Now that I've messed with it today, I'm glad I found your solution right away! :)
[G1 Android Development] hawst:
Hi, it's i'm again ;). This issue is fixed by small workaround, i was recontructed file using 'aapt dump', there was similar file near. So WorldClock is now packed ok. (I mean that i was made work for apktool by unpacking 'undim.html' ;)

Have few another errors, can u please advise me.

Some files unpacked with this error:

I: Decoding resource table...
I: Decoding resources...
Exception in thread "main" brut.androlib.AndrolibException: brut.directory.PathNotExist: res
at brut.androlib.res.AndrolibResources.decode(Unknown Source)
at brut.androlib.Androlib.decodeResourcesFull(Unknown Source)
at brut.androlib.ApkDecoder.decode(Unknown Source)
at brut.apktool.Main.cmdDecode(Unknown Source)
at brut.apktool.Main.main(Unknown Source)
Caused by: brut.directory.PathNotExist: res
at brut.directory.AbstractDirectory.getDir(Unknown Source)
... 5 more

Does it mean that there is no 'res' folder inside ? So no need to repack this file, right ?

Some are unpacked with another error:

I: Decoding resource table...
Exception in thread "main" brut.androlib.AndrolibException: Could not load resources.arsc from file: HtcSettingsProvider.apk
at brut.androlib.res.AndrolibResources.decodeArsc(Unknown Source)
at brut.androlib.res.AndrolibResources.getResTable(Unknown Source)
at brut.androlib.Androlib.getResTable(Unknown Source)
at brut.androlib.ApkDecoder.getResTable(Unknown Source)
at brut.androlib.ApkDecoder.decode(Unknown Source)
at brut.apktool.Main.cmdDecode(Unknown Source)
at brut.apktool.Main.main(Unknown Source)
Caused by: brut.directory.PathNotExist: resources.arsc
at brut.directory.AbstractDirectory.getFileInput(Unknown Source)
... 7 more

Does it mean that there is no resources at all ? So such file also dont require to be repacked, right ?
[G1 Android Development] smjfosho:
hey, im having trouble getting this to work, im running the latest ubuntu, and im not sure even how to get started, any help is greatly appreciated.
[G1 Android Development] Brut.all:
@hawst

You could add "-r" switch to not decode resources. I know it's stupid, apktool should guess you want to use it - I will fix this.

And that first error is strange: there is resources.arsc, but not "res" dir in this apk?
[G1 Android Development] hawst:
I think at 1st you should try to handle .html files as .xml, coz here it was such way.

I dont know, can u please check attachment (.txt is result of

aapt.exe d resources CheckinProvider.apk

command ?
[G1 Android Development] HomerSp:
Hi brut.all, I read some about how the resources need to be public in the framework for apktool to be able to use them. Could you expand a bit more on how to accomplish this? I did the aapt command and got the flags, but some of them are just 0x00000000 which makes it nearly impossible to hex edit.

Thanks for your hard work.
[G1 Android Development] Brut.all:
Apktool doesn't require resources to be public - some apps need them. If you try to build e.g. system apps in usual way, from sources, you will fail, because they use some private APIs and resources - standard building mechanisms won't allow you to use these private bits. Apktool must be able to build all apps, including system ones, so for them we must hack framework resources :-)

Screw hex editing, just run "apktool publicize-resources resources.arsc" and voila :-) This isn't documented, because I have added this feature for myself ;-)

P.S.

Change this avatar. I have always problems to focus on what you are saying ;-)
[G1 Android Development] HomerSp:
Oh, I had no idea such a command existed, thanks a lot! :)

Hehe, that's why I use it ;)
[G1 Android Development] HomerSp:
Okay, it worked fine for the htc framework, but on the android framework I get an exception when trying to build an apk:

W/ResourceType( 6737): Unable to get buffer of resource asset file

and after that there are a bunch of

No resource found that matches the given name '@android:...'
[G1 Android Development] Brut.all:
I don't know exactly, but this is related to compression algorithm used to compress resources.arsc file in framework apks. I use no compression, forgot to write that in above instructions.
[G1 Android Development] HomerSp:
Oh right, thanks. It works now :D
[G1 Android Development] bitizx:
Help! Got an error

I also have trouble decoding Beautiful widgets, got an error like this:

F:\apktool1.1.1>apktool d "F:\Beautifulwidgets.v2.992.apk" "F:\test"

I: Baksmaling...

I: Decoding resource table...

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 11020

at brut.androlib.res.decoder.StringBlock.getShort(Unknown Source)

at brut.androlib.res.decoder.StringBlock.getString(Unknown Source)

at brut.androlib.res.decoder.ARSCDecoder.readValue(Unknown Source)

at brut.androlib.res.decoder.ARSCDecoder.readEntry(Unknown Source)

at brut.androlib.res.decoder.ARSCDecoder.readConfig(Unknown Source)

at brut.androlib.res.decoder.ARSCDecoder.readType(Unknown Source)

at brut.androlib.res.decoder.ARSCDecoder.readPackage(Unknown Source)

at brut.androlib.res.decoder.ARSCDecoder.readTable(Unknown Source)

at brut.androlib.res.decoder.ARSCDecoder.decode(Unknown Source)

at brut.androlib.res.AndrolibResources.loadArsc(Unknown Source)

at brut.androlib.res.AndrolibResources.decodeArsc(Unknown Source)

at brut.androlib.res.AndrolibResources.getResTable(Unknown Source)

at brut.androlib.Androlib.getResTable(Unknown Source)

at brut.androlib.ApkDecoder.getResTable(Unknown Source)

at brut.androlib.ApkDecoder.decode(Unknown Source)

at brut.apktool.Main.cmdDecode(Unknown Source)

at brut.apktool.Main.main(Unknown Source)
[G1 Android Development] HomerSp:
Hi again, did you ever find any solution to issue #30?

I'm trying to rebuild framework-res.apk, but unlike you I only get one error:

/home/homer/Android/Development/Sense/out/res/values/public.xml:2453: error: Public entry identifier 0x1080331 entry index is larger than available symbols (index 817, total symbols 817).
/home/homer/Android/Development/Sense/out/res/values/public.xml:2453: error: Public symbol drawable/selected_day_background declared here is not defined.
[G1 Android Development] cytown:
Well done guy. I will sure use it sometime.
[G1 Android Development] atrant:
Hi! very very good utility =) at least for unpacking )) but I've seen the difference between your smali-files and baksmali utility generated files.

And I have one apk which gets an error.
[G1 Android Development] Skin1980:
do you kno how i can add an entry in the public.xml file (of Launcher.apk) ?

If i add to it i can't rebuild the apk.....
[G1 Android Development] Brut.all:
And why do you want to add something there? This file is intended mainly for framework resources, not regular apps. I use it to workaround some problem.
[G1 Android Development] Brut.all:
There are many completely new features - report any issues.

Also old projects won't work with new apktool cause of lacking apktool.yml meta file. If you have some changes and don't want to lose them, you could decode same apk using new apktool and copy apktool.yml file.
[G1 Android Development] udK:
Thank you Brut.all, will test it tomorrow.
[G1 Android Development] stari4ek:
Sweet.

I'll finish today's rom build with old apktool, and give it a try tomorrow.

Nice to see, that you continue work on it. Thank you.
[G1 Android Development] Daneshm90:
Just wanted to drop in and say awesome stuff. Thanks to this i was able to modify my apps to suit my needs, like the xda app and its ignorance of "global orientation setting". Thanks.
[G1 Android Development] Brut.all:
Little update:

Sorry, I've forgotten about newer aapt requirement.

EDIT:

Let me know, whether this works on macosx - its aapt file is much smaller in this version, much smaller than for linux, so maybe it depends on some other files.
[G1 Android Development] capychimp:
thx for the update :)