yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] pendo:
To be clear, what I meant about injecting them is to take the original .9.png (prior to using apktool) then inject that into the framework-res.apk AFTER you finish with apktool. ***Be sure to remove the version that apktool renamed, or else whatever is calling it will call the wrong image!

There's another--probably best--option. Take all of the images that apktool renames without the .9 and open them in draw9patch. It will help you fix them and apktool won't rename them at all.

It's kind of a pita if you have a lot of them, but it is the most proper way to deal with them.
[G1 Android Development] ihtfp69:
Gotcha. Thanks for the info. I will be trying that approach to hopefully fix this issue.

EDIT: fixed the problem with the patch 9 files by upgrading apktool to the latest. The reason, I was running an older version was because the newest one messes up resources when it decompiles. So I have a fully working framework file now, but had to use both versions of apktool to get it. Certainly not ideal, but at least I solved my problem. Thanks for the help.
[G1 Android Development] M@XLOL:
I've pulled and edited my android policy jar to enable vanilla lockscreen.

I am trying to compile the folder 'android.policy.jar.out' back to android.policy.jar

Here's my error I have no idea where to carry on from here

max@max-desktop:~$ apktool b '/home/max/android.policy.jar.out' android.policy.jar
I: Checking whether sources has changed...
I: Smaling...
Exception in thread "main" java.lang.NullPointerException
at org.jf.util.PathUtil.getRelativeFile(Unknown Source)
at org.jf.smali.smaliFlexLexer.getSourceName(Unknown Source)
at org.jf.smali.smaliFlexLexer.getErrorHeader(Unknown Source)
at org.jf.smali.smaliFlexLexer.nextToken(Unknown Source)
at org.antlr.runtime.CommonTokenStream.fillBuffer(Unknown Source)
at org.antlr.runtime.CommonTokenStream.LT(Unknown Source)
at org.jf.smali.smaliParser.smali_file(Unknown Source)
at brut.androlib.mod.SmaliMod.assembleSmaliFile(Unknown Source)
at brut.androlib.src.DexFileBuilder.addSmaliFile(Unknown Source)
at brut.androlib.src.DexFileBuilder.addSmaliFile(Unknown Source)
at brut.androlib.src.SmaliBuilder.buildFile(Unknown Source)
at brut.androlib.src.SmaliBuilder.build(Unknown Source)
at brut.androlib.src.SmaliBuilder.build(Unknown Source)
at brut.androlib.Androlib.buildSourcesSmali(Unknown Source)
at brut.androlib.Androlib.buildSources(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)
[G1 Android Development] djmcnz:
/out not .out

Look at the files...?
[G1 Android Development] M@XLOL:
the name of the folder I am trying to compile is 'android.policy.jar.out'

I believe my command to be correct. If not can you clarify a bit I am out in deep water thanks a lot.
[G1 Android Development] djmcnz:
So you manually decoded it to (or moved it to) 'android.policy.jar.out'? Because that's not a typical location.

Rename the dir to 'policy' and try again.
[G1 Android Development] M@XLOL:
When I decompile the jar without editing anything I can recompile fine with same original output name. There must be an error with my edt. I will try when I get home thank you.
[G1 Android Development] ihtfp69:
Using smali by itself to compile might give you a clearer error message if the problem is indeed in your edit. There have been several changes to smali since this program was last compiled.
[G1 Android Development] pendo:
Actually I believe that's correct dj. If you don't specify an output, then that's what apktool names the output folder

I'm playing with services.jar from miui right now, and if I use this command: "apktool d services.jar" then I get an output folder services.jar.out

It looked strange to me at first, but that's because out of habit I'm used to using baksmali and specifying output with -o
[G1 Android Development] kycaver:
Just what I was looking for
[G1 Android Development] javroch:
I've tried searching to the best of my ability, but I can't find anything on the subject. When I try and re-encode Twitter.apk (the most recent one) for example, the apk force closes whenever the smali tries to access a sound file, using SoundPool, in /res/raw. I've been also having the same issue with swype since it tries to play /res/raw/beep.wav and when it does I get FC's. When I look at the logcat, it's complaining that these resources are compressed and shouldn't be. I've been at a loss for a couple of days. For twitter, what I've been able to do is remove the code that accesses the file in smali, but I feel like there should be a better answer.
[G1 Android Development] BluechipJ:
Can this be used to decompile system apps?

I've been trying to decompile the Phonebook.apk (http://www.multiupload.com/2M7SQEA327) for the Xperia X10 to simply remove the vibrate/haptic from the dial pad.

From my rudimentary exploring, it seems to be TwelveKeyDialer.smali, line 1890:

invoke-direct {p0}, Lcom/sonyericsson/android/socialphonebook/TwelveKeyDialer;->vibrate()V

However, I'm getting errors when decompiling and can't get far enough to recompile.

The error I'm getting is:

I: Baksmaling...
I: Loading resource table...
I: Decoding resources...
I: Loading resource table from file: C:\Users\Analyst\apktool\framework\1.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=background, value=0x01080482
Exception in thread "main" brut.androlib.err.UndefinedResObject: resource spec:0x0103011a
at brut.androlib.res.data.ResPackage.getResSpec(Unknown Source)
at brut.androlib.res.data.ResTable.getResSpec(Unknown Source)
at brut.androlib.res.data.ResTable.getResSpec(Unknown Source)
at brut.androlib.res.data.value.ResReferenceValue.getReferent(Unknown Source)
at brut.androlib.res.data.value.ResReferenceValue.toResXmlFormat(Unknown Source)
at brut.androlib.res.data.value.ResStyleValue.serializeToXml(Unknown Source)
at brut.androlib.res.AndrolibResources.generateValuesFile(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)

If anyone can point me in the right directly, it'd be appreciated.
[G1 Android Development] mazdac:
I got this sam issue installing Brut's modded google maps app. To install app that causes this error you have to edit /dbdata/system/packages.xml and remove everything related to this app, reboot and install it. For me, this method works fine.
[G1 Android Development] djmcnz:
Are you sure? Do other apps with the same ID still work? I would think that as package manager rebuilds it will still find the conflicts and will fail to load conflicting apps. Maps just may load fist and therefore pass the test.

Or I may be wrong... :)
[G1 Android Development] mazdac:
I don't know how it works with more than one app with this same id ;) I just deleted entries related to google maps and deleted orginal Maps.apk, then installed brut's Maps.apk (so it is replacement). Without editing xml I couldn't even install brut maps (Failure [INSTALL_FAILED_SHARED_USER_INCOMPATIBLE]).

If something doesn't work (i got this:

java.lang.SecurityException: Permission Denial: writing com.android.providers.downloads.DownloadProvider uri content://downloads/download from pid=4712, uid=10034 requires android.permission.ACCESS_DOWNLOAD_MANAGER

which means I couldn't download anything from market, just pull app from system (adb pull) and reinstall it (adb install -r), after that market started working and downloading again, but i don't know that this error was caused by modified packages.xml or by me (i have accidentally changed permissions to files in /system/app :P).
[G1 Android Development] djmcnz:
Interesting, thanks I might have a look at that.
[G1 Android Development] Patriot Virus:
What do I need to d/l to run apktool? I have apktool on my desktop but when clicking exe it open and closes.
[G1 Android Development] pendo:
did you try to install sony resources first?

pull the framework-res.apk and call it like this:

apktool if framework-res.apk sony

(I just used sony as an example you can tag it however you wish)

Then go back and do :

apktool d -t sony Phonebook.apk

use -f switch to force overwrite if necessary.
[G1 Android Development] Jimmothy:
I've modified 4 icons in Mms.apk and I've made an update.zip with just enough to flash Mms.apk, I've done the same resigning Mms.apk, I've done the same resigning and flashing all of system/app/*.apk and either way it force closes Mms.apk when I try open it. I'm using the latest version of apktool to decompile and rebuild Mms.apk and dsixdas kitchen to resign all the apks.

What am I doing wrong?

I also used the original META-INF and mainifest.xml too.

Any help is appreciated.

EDIT: Managed to do it with version 1.3.0
[G1 Android Development] djmcnz:
[SOLVED] Public symbol [...] declared here is not defined

Solution:

Edit #2: I've just found the problem... when I updated the SDK to 2.3 it replaced aapt.exe with a version incompatible with apktool... reverted to old and it works again... :)

I can no longer build framework-res.apk, I get screens of:

E:\Android\APKTool\framework-res\res\values\public.xml:1928: error: Public symbol string/permlab_camera declared here is not defined.
E:\Android\APKTool\framework-res\res\values\public.xml:2006: error: Public symbol string/permlab_changeBackgroundDataSetting declared here is not defined.
E:\Android\APKTool\framework-res\res\values\public.xml:1884: error: Public symbol string/permlab_changeComponentState declared here is not defined.

This was with an unchanged CM-6.1.0 Stable framework. So I went back and tried with a previous framework that I had successfully changed and I received the same errors. Something has changed on my system it seems, what causes this message?

I have changed both my decode and encode scripts to manually load the correct framework before they call apktool and have verified this:

I: Framework installed to: C:\Users\djmcnz\apktool\framework\1.apk

So, whereas 10 days ago I could decode/modify/encode, now I can't even decode/encode with any framework...

I have updated my SDK to 2.3 which is the only change I can think of, seems to work, adb, java and eclipse are all cool...

I'm not a doofus but this one's got me pinched... what's the root cause of this message? I must be able to reverse whatever change has happened on my system...

v1.3.2 of apktool of course.

:(

Edit/correction: it happens for all apks now...
[G1 Android Development] pendo:
dj,

Is the error erroneous, or are those strings really missing? Also, I know you said you verified that you are loading the right framework for your script, but have you tried it the "normal" way?

fwiw, I've been using 1.3.1 on cm6.1 with no issues. I'm not calling any tags either.
[G1 Android Development] djmcnz:
Erroneous... and I made a last minute edit to my post, it occurred with all apks!

But I've just found the problem... when I updated the SDK to 2.3 it replaced aapt.exe with a version incompatible with apktool... reverted to old and it works again... :)
[G1 Android Development] pendo:
Hm....I'm updated as well, but haven't had any problems and I've probably called apktool ~20 times today. :confused:

I probably should have an old version of aapt handy then...

<edit>

Nevermind...I forgot to engage my brain before I engaged my keyboard. I didn't put the new aapt in /usr/local/bin...looks like my negligence worked in my favor this time!
[G1 Android Development] vido.ardes:
can someone upload an old version of aapt or point me to where I can get hold of it? Thanks!
[G1 Android Development] djmcnz:
It a bastard isn't it!

It's in "apktool-install-windows-2.2_r01-3.tar.bz2" which you can get from here: http://code.google.com/p/android-apktool/
[G1 Android Development] vido.ardes:
Thanks, but I'm still getting the same errors djmcnz was, can someone see if this compiles for them?
[G1 Android Development] djmcnz:
I get the same errors using your files but I probably need your framework-res.apk to load (I'm using a Nexus/CM6.1 one)? If your attach you one I'll give it another go for you.
[G1 Android Development] vido.ardes:
I am doing this for the HTC Hero, but this was the only active topic I could find about APKTool. I just want to chane one small XML file, and it decompiles fine, but I can't re-compile it. It's really bugging me!

File is attached, thanks for trying it.
[G1 Android Development] djmcnz:
:(

Same errors I'm afraid so perhaps your issue is a different one? Unfortunately I personally don't have the time to look further into it at the moment.

If you can build other apks then you can safely narrow your search down to framework-res.apk because it is different. However, with my most recent issue, no apks (even simple ones) could be built.
[G1 Android Development] vido.ardes:
OK, thanks for looking
[G1 Android Development] pendo:
Here, try this. The version of apktool that I have didn't like a few of your 9patch files in your first post. So I downloaded the actual frame-res.apk and it decompiled, but only by dropping the 9patch. I swapped out the "bad" 9patches from your first post, and it compiled fine for me.

Fwiw, the 9patch files it changed to regular png so you know what to expect:

drawable/quickcontact_nobadge_highlight.9.png

drawable/quickcontact_nobadge_normal.9.png

drawable/quickcontact_nobadge_pressed.9.png

drawable-mdpi/status_bar_header_background.9.png

drawable-mdpi/title_bar_portrait.9.png​
[G1 Android Development] fllash:
To anyone who has more of an idea than I do regarding apktool:

Every time I try to decompile (which always works fine) and then recompile, I always get errors recompiling.

For example, decompiling phone.apk (with the command apktool d phone.apk) works fine, but when I choose to recompile it (with apktool b phone) I get the following error message:

C:\Users\Josh\Desktop\NF>apktool b phone

I: Checking whether sources has changed...

I: Checking whether resources has changed...

I: Building resources...

C:\Users\Josh\Desktop\NF\phone\res\layout\adn_list.xml:8: error: No resource identifier found for attr

lectorOnNothing' in package 'android'

aapt: warning: string 'menuButtonHint' has no default translation in C:\Users\Josh\Desktop\NF\phone\re

CN zh_TW

Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutException: could not exec

t, p, -F, C:\Users\Josh\AppData\Local\Temp\APKTOOL3105020204293797737.tmp, -I, C:\Users\Josh\apktool\f

k, -S, C:\Users\Josh\Desktop\NF\phone\res, -M, C:\Users\Josh\Desktop\NF\phone\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, C:\Users\Josh\AppData\Loca

L3105020204293797737.tmp, -I, C:\Users\Josh\apktool\framework\1.apk, -S, C:\Users\Josh\Desktop\NF\phon

\Users\Josh\Desktop\NF\phone\AndroidManifest.xml]

at brut.util.OS.exec(Unknown Source)

... 7 more

I have tried various combinations of apktool.jar and aapt.exe.

Does anyone have an inkling as to why apktool is falling over all the time?

Josh.
[G1 Android Development] pendo:
Thought I'd try to help. I assumed it was miui, and when I decompiled phone.apk I get the exact same errors. The error log says it all, there's no reference to 'menuButtonHint' in the values folder, even though it's mentioned in the other language folders. I went back and tried 12.3 and 11.26 as well and they do not have this error.

The other error is a little puzzling, because I've never heard of 'drawSelectorOnNothing' There's a "drawSelectorOnTop". But just because I've never heard of it doesn't mean much, lol, as I'm far from an expert. But I've got to wonder if this was a translation bobble?

So for kicks I just added this to strings.xml in values folder:

<string name="menuButtonHint">Press menu for call options</string>

Then on line 8 of adn_list.xml in layout I changed "drawSelectorOnNothing" to "drawSelectorOnTop" and it compiled just fine :)

Disclaimer: I'm not running miui presently, and have not verified the legitimacy of that work around. I'm just offering a mostly un-educated opinion.

Here's info on drawSelectorOnTop:

http://developer.android.com/reference/android/widget/AbsListView.html#attr_android:drawSelectorOnTop
[G1 Android Development] fllash:
It turned out that i had not entered the command:

apktool if framework-res.apk - and hence had no resource tables.

Now stuff compiles fine.

Thanks for the reply :)

Josh.
[G1 Android Development] pendo:
Oh, lol....I made it way too hard then. I know you always have to do that with sense stuff. I think maybe I've been on the computer too long, need to take a break, lol. :)
[G1 Android Development] fllash:
Bummer, almost had it - everything compiled correctly, but doesn;t get recognized inside android.

I de then re compiled launcher2.apk, and inserted it into the rom flashable zip, but when i flashed it, and rebooted, after completing the setup wizard when the launcher would normally load, the setup wizard FC's and nothing happens - pressing home does nothing. It looks like the launcher wasent recognised.

I know its a long shot :P, but any ideas?
[G1 Android Development] djmcnz:
Many of those apps are system apps and need the same signatures as other apps in /system/app - how are they signed?

If you don't know then try removing the "SharedUserID" entry in AndroidManifest.xml and recompile, push to phone, see if that works.... it's a work-around.
[G1 Android Development] pendo:
Thanks for that tip....didn't know that one.;)
[G1 Android Development] MrHassell:
great!

I've been using this and have to say that this is really cool.

Leads me thinking more about the structure of APK files being renamed zip files and how to obfuscate this kind of packages contents. Being that commercial packages are also stored in this format, it makes it really quite a powerful tool and exposes one of the single biggest problems with application packaging present today.

Quite clearly this project is covering a lot of ground for HTC specific issues and I look forward to following this further. Thank you for the heads up!

;)
[G1 Android Development] BlackDino:
Edit -- I am an idiot
[G1 Android Development] pendo:
lol...Monday's :D
[G1 Android Development] luhu:
I think I'm to stupid for this...

How can I decode an apk file in the command line in Windows?

I need only what to type in...
[G1 Android Development] pendo:
umm.... so you have everything in the correct directories?

Everything is right there on the front page of http://code.google.com/p/android-apktool/

just type "apktool" without the quotes and hit enter....it will list all of the commands available.
[G1 Android Development] luhu:
Yes, everything is in the right directory and I get the list of the commands when I'm typing in apktool. But don't know what to type. In what format...

e.g.: apktool Decode path/apk.apk to path/folder

or apktool [-v¦--verbose] d

.....

Maybe you can give me only the format, that would be enough for me to understand :)
[G1 Android Development] luhu:
Ok, I tried Apk Manager 4.9 and this worked fine, with a graphic UI ;)
[G1 Android Development] Jonathan_m84:
this is awesome, thanks for posting! :)
[G1 Android Development] Droidzone:
The program reduces the size of the apk file by about 30%. Some of my recompiled apks are force closing. Plus black display on screen. Maybe some dependencies?
[G1 Android Development] pendo:
The compression has been covered before in this thread many times...it's just using a newer/better compression than when your apk was originally compiled.

As far as the other issues, there is a known bug in 1.3.2 that decompiles some xml's incorrectly. You should use 1.3.1. It is for the most part error free, I use it all the time. :)
[G1 Android Development] RaiBinger:
Hi All!

I trying to decompil framework-res.apk from LG GT540 Optimus on firmware 2.1-update-1.

Log cmd in process to decompil apk:

D:\Android\SDKTools\tools>apktool d -d C:\themes\mytheme.apk C:\themes\mytheme\decoded\
I: Loading resource table...
I: Decoding resources...
I: Copying assets and libs...

And log process try to compil apk without any changes:

D:\Android\SDKTools\tools>apktool b -d C:\themes\mytheme\decoded C:\themes\mytheme\encoded\mytheme-new.apk
W: Could not find sources
I: Checking whether resources has changed...
I: Building resources...
I: Building apk file...

How I understand, message "W: Could not find sources" is not critical error, but warning.

I trying apply apk with sign key and without him.

Trying it:

D:\Android\SDKTools\tools>java -jar signapk.jar certificate.pem key.pk8 C:\themes\mytheme\encoded\mytheme-new.apk C:\themes\mytheme\encoded\framework-
res.apk

But all my attempts failed.

The device is not loaded on logo LG.
[G1 Android Development] Droidzone:
Solved most of my issues while playing around it.

I just removed all elements other than Classes the apk file before decompiling. After all that was what I wanted to decompile. After recompiling, manually added the non-decompiled elements to the zip, packed it and then resigned.
[G1 Android Development] Anoniem100:
Whow, cool tool man!

I wrapped it all up into a little gui.

http://xdaforums.com/showthread.php?p=10129091#post10129091
[G1 Android Development] KBanause:
One question:

When I decompile a .apk file (Settings.apk or Phone.apk) I get this output:

D:\tests>apktool.bat d -s Settings.apk
I: Copying raw classes.dex file...
I: Loading resource table...
W: Skipping "android" package group
I: Decoding resources...
I: Loading resource table from file: C:\Users\marc\apktool\framework\1.apk
I: Copying assets and libs...

After I have changed some graphic files and push the recompiled file to the phone, I can't see any changes. Graphic files within the .apk are the new ones but the phone is using the old ones. My suspicion is that it has something to do the line

W: Skipping "android" package group

What exactly does that mean?
[G1 Android Development] Brut.all:
I think not. This warning is normal for many apks, I have added it because I don't understand what is the purpose of that "android" group which apktool removes.

Did you replaced old files or just added new ones? If you have removed old images, but device still displays them, then... you know, Android can't magically create something, it doesn't have ;-) - you had to miss something.
[G1 Android Development] KBanause:
After I recompiled it, I executed a script which converts all .png files to grayscale. Then I recompiled it, extracted the original .apk as zip file, deleted all .png files and copied all remaining files to my .apk file. Then I pushed it on to my phone in recovery and deleted /cache and all dalvik-caches.
[G1 Android Development] pendo:
Happy New Year Brut.all !

Good to see you in the thread again :)
[G1 Android Development] mhaque:
can someone please kindly modify the Dailer One app to search using hardware qwerty keyboard, instead of the T9. The developer is not responding to the request.

Thanks
[G1 Android Development] Ste11a:
I used the application to modify Springpad's widget to make it semi-transpartent. The editing feature worked perfectly. I packed the app after editing. Everything seems to work. But when I tried to install Springpad, it wouldn't install it. Am I doing something wrong?
[G1 Android Development] Brut.all:
And what is the error? Look into logcat.
[G1 Android Development] vgshah78:
where can i find v1.3.1? i searched for it but no luck. is it possible for you to up it? thx. :)
[G1 Android Development] KBanause:
http://tinyurl.com/2avmdmb

;)
[G1 Android Development] vgshah78:
@KBanause: lol..i already did that mate but the current version is 1.3.2 and even on project page there is no link for downloading prior versions.. :)