• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root [Guide] How-To Properly Decompile and Recompile apk's with apktool

LDrifta

No Stranger 2 Danger
Jun 7, 2011
3,907
3,202
35
Lynn, MA
How-To: Decompile/Recompile apk's with ApkTool

------------------------------------------------------------------------------------------------------------
Requirements:


ApkTool
Java JDK/JRE 32 bit
Basic Cmd/terminal knowledge


------------------------------------------------------------------------------------------------------------
Download ApkTool here


[Link removed]

first you need to extract that zip folder to anywhere you choose, preferably on root of c/drive ie: C:/android/apktool extracting the files to 'apktool' folder

Now place the STOCK framework-res.apk & whatever other apk's you would like to modify into the 'apktool' folder

------------------------------------------------------------------------------------------------------------
Getting to CMD directory



Open up a Cmd Prompt (terminal) and get to the 'apktool' directory ie:

Your cmd will probly look like this..

C:\users\yourname>

so type in

cd.. (yes include the '..' and press enter after you type each command)

this will get you to back directory so now you will see

C:\users>

so type again

cd..

you should now see this:

C:\>

now type in:

cd 'apktoo'l/'directory'

for me it looks like:

cd android/apktool

now you should see:

C:/android/apktool>

and you are in the apktool directory :D

------------------------------------------------------------------------------------------------------------
Installing Framework


Now that you are in directory we need to install the device's framework to your system for it to compile correctly so type this:

apktool if framework-res.apk

this will install the devices framework to your system (need to do this)

------------------------------------------------------------------------------------------------------------
Decompiling


now to decompile the apk you want to edit.. type this:

apktool d framework-res.apk framework1

or

apktool d music.apk music

music.apk is the apk your decompiling
music is the folder you're creating for the decompiled apk

now make your edits :D DO NOT Change/Edit ANY PNG's

------------------------------------------------------------------------------------------------------------
Recompiling/Finished Product


now to recompile your new apk type this:

apktool b music music-new.apk

or

apktool b framework1 framework-res-new.apk

framework1 is the folder with your edited files
framework-res-new.apk is your new apk file :D

Now we are NOT done... we cannot use the new apk's... we have to take what we did and add it back to the original apk file to keep proper signature :D

use something like 7zip, take the 'resources.arcs' file and any other xml files you edited out of the "-new" apk and copy them into Original apk

now the apk is ready to flash with your new changes :D :D
------------------------------------------------------------------------------------------------------------


Hope this helped some of you new themers out there!!!
 
Last edited by a moderator:
I extracted to my desktop then moved adb and related files to the platform tools folder inside the apk manager file.

And just a tip on to know if you did everything right is, when you run apk manager and the window pops up if a green android and "apk manager" does show in the first window when you start it up it wasn't set up right.
this method is just for on the computer no adb required...
 
Upvote 0
Ok..
If i understand correctly.
Say i wanted to decompile any .apk to poke around the files.

When i put the APKtool in the correct directories i then typed in command line the command calling on the apktool if framework-res.apk.

It doesn't find it in the folder.So i downloaded framework-res.apk from another location and did command again,then it saw it and decompiled it.

I'm sure already you can conclude i'm not really familiar with this. Any help will be useful
 
Upvote 0
Ok..
If i understand correctly.
Say i wanted to decompile any .apk to poke around the files.

When i put the APKtool in the correct directories i then typed in command line the command calling on the apktool if framework-res.apk.

It doesn't find it in the folder.So i downloaded framework-res.apk from another location and did command again,then it saw it and decompiled it.

I'm sure already you can conclude i'm not really familiar with this. Any help will be useful
lol you need to have the framework apk in same directory ask apktool.bat, apktool.jar and aapt.something.. lol
your not installing it to your phone lol to your computers system :D

EDIT: i apologize, let me explain a little further.. when decompiling an apk file, especially a system required apk such as settings, systemui, etc.. you NEED to install the framework resources before decompiling so it will properly recompile:D

so you dont NEED to do it everytime, but you must do it the first time.. as long as it installs than you will be ok
 
Upvote 0
lol you need to have the framework apk in same directory ask apktool.bat, apktool.jar and aapt.something.. lol
your not installing it to your phone lol to your computers system :D

EDIT: i apologize, let me explain a little further.. when decompiling an apk file, especially a system required apk such as settings, systemui, etc.. you NEED to install the framework resources before decompiling so it will properly recompile:D

so you dont NEED to do it everytime, but you must do it the first time.. as long as it installs than you will be ok

Ok i did that and its working now. Thanks

Is there some sensitive parts of the .APK that might hender it?

EDIT: Oh im glad i can bring you such laughter..with my questions. ha ha
Thanks again
 
Upvote 0
I will have to find the time to learn where those files are located in each .APK and know what different changed can be done. Lol:D


Thank you
yeah there not really a way to learn that specific thing at one time.. it's kinda a leran as you go deal with each ind. apk lol some are harder to edit than others..
 
  • Like
Reactions: BRIAN5337
Upvote 0
i'm stuck at the end of this tutorial... i'm able to recompile my apk but... you said we can't use it because it was obviously signed... but whenever i copy the resources.arcs and manifest file into the 'original' apk... and then i try to reinstall it... i keep getting " INSTALL_PARSE_FAILED_NO_CERTIFICATES...

please help... all i'm trying to do is this application i'm assessing has the debugging statement listed as 'false'... all i'm trying to do is
1. decompile
2. modify debbugable to TRUE
3. recompile
4. install and analyze the logcat

HELP TIA
 
Upvote 0
i'm stuck at the end of this tutorial... i'm able to recompile my apk but... you said we can't use it because it was obviously signed... but whenever i copy the resources.arcs and manifest file into the 'original' apk... and then i try to reinstall it... i keep getting " INSTALL_PARSE_FAILED_NO_CERTIFICATES...

please help... all i'm trying to do is this application i'm assessing has the debugging statement listed as 'false'... all i'm trying to do is
1. decompile
2. modify debbugable to TRUE
3. recompile
4. install and analyze the logcat

HELP TIA
what app are you trying to do this to? for what rom and what kernel do you have?
 
Upvote 0
Everytime I try to compile an APK I get an error.

Im not doing it through ADB, Im running it all on my computer and editing them first and then pushing them to the phone. But I cant get an apk to work because I cant compile???
what apk are you trying to edit? if it's non-stock than you will have issues lol you need to use stock apk, and ONLY edit xml files... DO NOT edit your png files when decompiling/recompiling!!!
 
Upvote 0
what apk are you trying to edit? if it's non-stock than you will have issues lol you need to use stock apk, and ONLY edit xml files... DO NOT edit your png files when decompiling/recompiling!!!


I started using AutoApktool and it's working a lot better. I like having the stand alone interface too. I wasn't using Apktool before, it was ApkEdit and that was the one that I couldn't compile with. I tried to compile with Tool and it worked fine but I liked having the interface from which I came across AutoApk and it's much easier. No commands and all that. :D
 
Upvote 0
Is there a problem when it comes to decompling Phone.apk?

Code:
C:\apk>apktool if framework-res.apk
I: Framework installed to: C:\Users\MM\apktool\framework\1.apk

C:\apk>apktool d Phone.apk
I: Baksmaling...
testI: Loading resource table...
W: Skipping "android" package group
I: Loaded.
I: Loading resource table from file: C:\Users\MM\apktool\framework\1.apk
I: Loaded.
I: Decoding file-resources...
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x02020350
W: Could not decode attr value, using undecoded value instead: ns=android, name=
textSize, value=0x020b0021
W: Could not decode attr value, using undecoded value instead: ns=android, name=
layout_height, value=0x020b00a0
W: Could not decode attr value, using undecoded value instead: ns=android, name=
layout_width, value=0x020b008b
W: Could not decode attr value, using undecoded value instead: ns=android, name=
layout_height, value=0x020b008a
W: Could not decode attr value, using undecoded value instead: ns=android, name=
src, value=0x02020187
W: Could not decode attr value, using undecoded value instead: ns=android, name=
textSize, value=0x020b0094
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x02020350
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x020204d6
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x020200f8
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x02020354
W: Could not decode attr value, using undecoded value instead: ns=android, name=
textSize, value=0x020b0021
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x0202003f
W: Could not decode attr value, using undecoded value instead: ns=android, name=
text, value=0x020800ae
W: Could not decode attr value, using undecoded value instead: ns=android, name=
text, value=0x02080172
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x020202d4
W: Could not decode attr value, using undecoded value instead: ns=android, name=
button, value=0x0202011c
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x020204cf
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x0201002b
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x0202013f
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x02020349
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x0202034b
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x0202034a
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x020204cb
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x020204cb
W: Could not decode attr value, using undecoded value instead: ns=android, name=
layout_above, value=0x02090032
W: Could not decode attr value, using undecoded value instead: ns=android, name=
layout_above, value=0x02090032
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x02020114
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x02020114
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x02020114
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x02020356
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x02020354
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x02020357
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x02020357
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x02020357
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x02020355
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x02020354
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x02020356
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x020204cb
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x020204cc
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x020204cd
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x020204d4
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x02020399
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x020204d6
W: Could not decode attr value, using undecoded value instead: ns=android, name=
textSize, value=0x020b00e0
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x02020354
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x020204cb
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x020204cc
W: Could not decode attr value, using undecoded value instead: ns=android, name=
drawable, value=0x020204cd
W: Could not decode attr value, using undecoded value instead: ns=android, name=
src, value=0x020204d4
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x02020399
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x02020344
W: Could not decode attr value, using undecoded value instead: ns=android, name=
layout_height, value=0x020b00a0
W: Could not decode attr value, using undecoded value instead: ns=android, name=
layout_width, value=0x020b008b
W: Could not decode attr value, using undecoded value instead: ns=android, name=
layout_height, value=0x020b008a
W: Could not decode attr value, using undecoded value instead: ns=android, name=
src, value=0x02020187
W: Could not decode attr value, using undecoded value instead: ns=android, name=
textColor, value=0x020a0026
W: Could not decode attr value, using undecoded value instead: ns=android, name=
textSize, value=0x020b0094
W: Could not decode attr value, using undecoded value instead: ns=android, name=
textColor, value=0x020a0036
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x02020101
W: Could not decode attr value, using undecoded value instead: ns=android, name=
divider, value=0x02020498
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x020204ca
W: Could not decode attr value, using undecoded value instead: ns=android, name=
textSize, value=0x020b00e4
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x02020430
W: Could not decode attr value, using undecoded value instead: ns=android, name=
layout_marginRight, value=0x020b00e5
W: Could not decode attr value, using undecoded value instead: ns=android, name=
src, value=0x020204d0
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x0202059a
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x0202056a
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x020205a1
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x0202059f
W: Could not decode attr value, using undecoded value instead: ns=android, name=
background, value=0x02020569
I: Decoding values*/* XMLs...
Can't find framework resources for package of id: 2. You must install proper fra
mework files, see project website for more info.
 
Upvote 0
Say you are editing in the values folder which turns into the resources file when compiled, and you make all your edits. Let's say you make some edits in the colors and public folder. You compile and transfer the resources over to your current fw and push it. Well you find that one of the edits in the colors folder isn't what you want.


Since you must use the stock fw and not the one you just edited do you have redo all your edits even though you want to change just one thing? You go back to change your edits in the colors xml, you have to change everything right?

If there an easier way to do this or am i doing it wrong?




Editing xmls in the layout or drawables folder is easier because they don't compile into one file like the resources. You can just edit it and compile and drag the xml over to your fw and if it's not what you want then all you have to do is edit that one file.
 
Upvote 0
Someone help me with this stupid error. Its driving me insane. Ive downgrade and re-upgraded apktool, used different mms and framework-res', changed the ic_mms_drm_protected.png to 50 million things, deleted it, and even switched to Easy apk disassembler (which my the way uses apktool) and so on and can not get past this dumb error

C:\apk>apktool b mmsesteem Mms-new.apk
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...
C:\apk\mmsesteem\res\drawable\ic_mms_drm_protected .PNG: error: File is case-inse
nsitive equivalent to: C:\apk\mmsesteem\res\drawable-hdpi\ic_mms_drm_protected.p
ng
Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutExce
ption: could not exec command: [aapt, p, -F, C:\Users\Adam\AppData\Local\Temp\AP
KTOOL6810626720324570876.tmp, -I, C:\Users\Adam\apktool\framework\1.apk, -S, C:\
apk\mmsesteem\res, -M, C:\apk\mmsesteem\AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(An drolibResources.jav
a:193)
at brut.androlib.Androlib.buildResourcesFull(Androlib .java:302)
at brut.androlib.Androlib.buildResources(Androlib.jav a:249)
at brut.androlib.Androlib.build(Androlib.java:172)
at brut.androlib.Androlib.build(Androlib.java:155)
at brut.apktool.Main.cmdBuild(Main.java:182)
at brut.apktool.Main.main(Main.java:67)
Caused by: brut.common.BrutException: could not exec command: [aapt, p, -F, C:\U
sers\Adam\AppData\Local\Temp\APKTOOL68106267203245 70876.tmp, -I, C:\Users\Adam\a
pktool\framework\1.apk, -S, C:\apk\mmsesteem\res, -M, C:\apk\mmsesteem\AndroidMa
nifest.xml]
at brut.util.OS.exec(OS.java:83)
at brut.androlib.res.AndrolibResources.aaptPackage(An drolibResources.jav
a:191)
... 6 more

C:\apk>
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones