[team d.i.r.t] how to properly de/recompile apks on all android versions!

Search This thread

evol4g

Senior Member
Mar 20, 2012
1,883
1,446
chandler-gilbert 480!!!
There is now a new person taking over the apktool project, his name is ibotpeaches.. His apktool works with every android version up to date.. This thread will now be a basic guide on how to use apktool :)

iBotPeaches' APKTOOL THREAD

What I do is create a folder to work in and call it for example:
Code:

c:\apktools

1) Take the apktool.jar from ibot's OP and the modded aapt he provided and place them in the folder.

2) You will need to pull the framework-res.apk from the rom you are working on. Copy it to c:\apktools.

4) Open a command window and navigate to your apktool folder
cd c:\apktools

5) We now need to install the framework and type the following:
java -jar apktool.jar if framework-res.apk

If you are decompiling any framework other that AOSP ie: sense, touchwiz, ect you will have to install the framework and systemui.apk for them as well, ie: for miui it's framework-miui-res.apk

You only need to do this once, unless you are working on a different Rom, then you will need to copy the framework-res.apk from that Rom and run the above command again.

6) We can now decompile framework-res with apktool
java -jar apktool.jar d framework-res.apk (here you can add the folder you'd like to have your extracted apk save to)
it will create a folder by the name of the .apk or .jar by default but say you wanted it just to go to a folder called "frameres" (just to be a lil more convienent while typing your command would look like this
java -jar apktool.jar d framework-res.apk frameres

the d option stands for decompile and you will now see a folder under c:\apktools\frameres (in my case, yours will be whatever your output folder's name is). Here is all the output and can make any changes you want, and then can recompile. I would test to make sure you can recompile before making a lot of changes though.


6) We will now compile framework-res.apk
java -jar apktool.jar b frameres NEWframework-res.apk
I always put something different in the new apk name for instance i always put NEWapk.apk some people use numbers like apk1.apk ect.. whatever you feel is comfortable for you.. But once you enter the command it will take a few minutes and it should complete without any errors.


7) Once it is done compiling you will need to go to c:\apktools\ and you will now see your new framework-res.apk in my case titled "NEWframework-res.apk"

IMPORTANT LAST STEP
Once you recompile the apk you're going to wanna use 7-zip to open both the original UNMODDED apk and the newly compiled apk
you wanna copy the META-INF folder and the AndroidManifest.xml from the ORIGINAL into the NEWLY compiled apk otherwise your apk won't work


Just remember to copy any apk you want to decompile right into the root of c:\apktools, run the decompile command and it will create a folder of the output that has the same of the apk file.
 
Last edited:

alteredlikeness

Senior Member
Mar 2, 2012
2,454
5,472
reflecting on Indra's net
Thanks for sharing and posting this! (I know there are similar threads scattered all over, but it's nice to see it fresh again). I am still on GB, but eagerly awaiting the update for ICS... Moto & AT&T - not quite a dynamic duo unfortunately...

And just to clarify a few things - what about the oem framework files, like moto/blur, touchwiz, etc..? I believe some apks require those to also be installed with apktool... and I've also read somewhere to install SystemUI.apk as well.. not sure if they are needed, but it doesn't hurt.

And at the end you mention for any xml edits to just copy the resources.arsc over to the old apk - but I think that is only for xml edits in the /values folders, that's what gets tucked in to the resources.arsc - one would still need to copy the edited and compiled xml from any other folder (like layout, anim, etc..), along with any other res changes...

Again, this is just my understanding, and I have my own ways that work well for me so far... and thanks for taking the time to put this thread together. Maybe it will serve as a sort of question and answer thread on the subject, as I have also seen many having troubles/questions..

Sent from my phone's mind
 

evol4g

Senior Member
Mar 20, 2012
1,883
1,446
chandler-gilbert 480!!!
Thanks for sharing and posting this! (I know there are similar threads scattered all over, but it's nice to see it fresh again). I am still on GB, but eagerly awaiting the update for ICS... Moto & AT&T - not quite a dynamic duo unfortunately...

And just to clarify a few things - what about the oem framework files, like moto/blur, touchwiz, etc..? I believe some apks require those to also be installed with apktool... and I've also read somewhere to install SystemUI.apk as well.. not sure if they are needed, but it doesn't hurt.

And at the end you mention for any xml edits to just copy the resources.arsc over to the old apk - but I think that is only for xml edits in the /values folders, that's what gets tucked in to the resources.arsc - one would still need to copy the edited and compiled xml from any other folder (like layout, anim, etc..), along with any other res changes...

Again, this is just my understanding, and I have my own ways that work well for me so far... and thanks for taking the time to put this thread together. Maybe it will serve as a sort of question and answer thread on the subject, as I have also seen many having troubles/questions..

Sent from my phone's mind

Yes your right for htc , Motorola, touchwiz and some others you do have to install the appropriate frameworks and in those cases systemui as well but most of them do not have 4.0.4 if I'm not mistaken.. I know HTC is on 4.0.3 but that's all I can truly account for.. but about copying resources.arsc is only if you made XML edits in the values folders, it does state that if other changes were made you'd have to copy those as well.. I will clarify that better thanks for pointing that out

Sent from my Nexus S 4G using xda premium
 

alteredlikeness

Senior Member
Mar 2, 2012
2,454
5,472
reflecting on Indra's net
Yes your right for htc , Motorola, touchwiz and some others you do have to install the appropriate frameworks and in those cases systemui as well but most of them do not have 4.0.4 if I'm not mistaken.. I know HTC is on 4.0.3 but that's all I can truly account for.. but about copying resources.arsc is only if you made XML edits in the values folders, it does state that if other changes were made you'd have to copy those as well.. I will clarify that better thanks for pointing that out

Sent from my Nexus S 4G using xda premium

Yea, Moto & Verizon just started last weekend - my buddy with a RAZR got the 4.0.4 update. I had a chance to do a system dump right away, then I decompiled the homescreen.apk just to take a look (I installed all 4 .apks in to apktool as I listed above for his system).

But, after I decompiled homescreen.apk I noticed that there were broken 9patch files already!! Before I even touched it. And that obviously messes up the compiling process - so I had to correct 6 or so broken .9.pngs - broken by Moto or Verizon, I can only assume - and after I repaired them everything compiled normally..

Just a heads-up that the "professional" devs mess up things also - and broken .9.pngs are often the cause for compiling errors..
 
  • Like
Reactions: evol4g

Ticklefish

Recognized Themer
Oct 27, 2011
6,744
8,543
Hampshire, UK
Well, this is very handy. :)

I'd thought I'd chip in and say that resources.arsc often needs to be compressed at the right rate as well. If it's not at 'store', in other words if the file in the apk is smaller than normal, the app might not work correctly.
 

a-id

Senior Member
Oct 9, 2010
160
180
makesmarterlife.blogspot.ru
Thanks for the useful information! Here is an archive of batch files that simplify the process. Enough to drag needed file or folder with mouse at appropriate batch file:

apktool-if.cmd - installation of framework-res, SystemUI, etc.
apktool-d-1.4.2.cmd - decompiling with apktool.jar.1.4.2.
apktool-d-1.4.3.cmd - decompiling with apktool.jar.1.4.3.
apktool-b.cmd - building.

Correct version of apktool is selected automatically.

Link: ApkTools-ICS-Simple.rar
 
Last edited:

myn

Retired Senior Recognized Developer
Nov 15, 2007
2,679
3,985
Thanks for sharing this info. I know a lot of people have been frustrated lately getting apks to properly decode and rebuild in ICS.

I took your great instructions and refined them a bit to reduce the workflow, having to rename the apktool.jar between decoding and building. You can download what I am using here.


  • First register framework-res by placing the framework-res.apk from your rom into the extracted apktool zip directory, then execute 0-FRAMEWORK-IF.BAT:

    Code:
    C:\Test\Test1.4.2-1.4.3>0-FRAMEWORK-IF.bat
    I: Framework installed to: C:\Users\Derek\apktool\framework\1.apk
  • Next decode the apk, 1-DECODE.BAT SystemUI.apk . A new output sub-directory will automatically be created based on the apk name (SystemUI.apk_out):

    Code:
    C:\Test\Test1.4.2-1.4.3>apktool-1.4.2.bat d SystemUI.apk ./SystemUI.apk_out
    I: Baksmaling...
    I: Loading resource table...
    I: Loaded.
    I: Loading resource table from file: C:\Users\Derek\apktool\framework\1.apk
    I: Loaded.
    I: Decoding file-resources...
    I: Decoding values*/* XMLs...
    I: Done.
    I: Copying assets and libs...
  • Make your edits and build. 2-BUILD.BAT SystemUI.apk:

    Code:
    C:\Test\Test1.4.2-1.4.3>2-BUILD.bat SystemUI.apk
    
    C:\Test\Test1.4.2-1.4.3>apktool-1.4.3.bat b -f -d SystemUI.apk_out
    I: Smaling...
    I: Building resources...
    I: Building apk file...

Download zip package
 
  • Like
Reactions: jobayer and evol4g

myn

Retired Senior Recognized Developer
Nov 15, 2007
2,679
3,985
Thanks for the useful information! Here is an archive of batch files that simplify the process. Enough to drag needed file with mouse at appropriate batch file:

apktool-if.cmd - installation of framework-res, SystemUI, etc.
apktool-d-1.4.2.cmd - decompiling with apktool.jar.1.4.2.
apktool-d-1.4.3.cmd - decompiling with apktool.jar.1.4.3.
apktool-b - building.

Correct version of apktool is selected automatically.

Link: ApkTools-ICS-Simple.rar

Awesome! Looks like we had the same idea in mind!
 

Ticklefish

Recognized Themer
Oct 27, 2011
6,744
8,543
Hampshire, UK
Originally Posted by a-id
It's not my merit, I just edited files a bit... :)

Awesome thank you guys both, seriously the lack of support for the editing of 4.0.4 apks was really limiting the possibilities of ics, nice to see support from you guys

Sent from my Nexus S 4G using Tapatalk 2

Apktool and ICS haven't been friends for ages..but there's a new version out now. Head here:

http://forum.xda-developers.com/showthread.php?p=28366939#post28366939

:)

This is designed to work with most ICS files. Some Sense files don't decompile properly but that's something HTC have done. That's nothing we can do about it.
 
Last edited:
  • Like
Reactions: a-id

evol4g

Senior Member
Mar 20, 2012
1,883
1,446
chandler-gilbert 480!!!

cristeaflorin2000

New member
May 17, 2010
3
0
Decompile Contacts.apk

I am trying o decompile any of the contacts.apk, logsprovider.apk or mms.apk to figure out a way to remove the SMS from call logs...anyone with an ideea how to accomplish this mission?
I have SGS2 with the new ICS 4.0.4 , XXLQ5
 

da-pharoah

Senior Member
Mar 24, 2009
2,779
1,593
Seacoast near Joppa
nice! thanks for redoing guide a guide like this!

---------- Post added at 12:41 AM ---------- Previous post was at 12:38 AM ----------

I am trying o decompile any of the contacts.apk, logsprovider.apk or mms.apk to figure out a way to remove the SMS from call logs...anyone with an ideea how to accomplish this mission?
I have SGS2 with the new ICS 4.0.4 , XXLQ5
your going to need to provide more info about your setup... custom rom or stock rom? and have you google'd this question yet?

edit:

ive found this app, will it work for you? Call Log & SMS Clear
 
Last edited:

cristeaflorin2000

New member
May 17, 2010
3
0
Not working for odexed ROMS

nice! thanks for redoing guide a guide like this!

---------- Post added at 12:41 AM ---------- Previous post was at 12:38 AM ----------

your going to need to provide more info about your setup... custom rom or stock rom? and have you google'd this question yet?

edit:

ive found this app, will it work for you? []

That ROM is fully stock and, ofcourse, odexed.It is rooted...i have google it for more than a week and tried all methods but nothing worked.That application u mentioned is doing the job(maybe) but manually.What i want is to find a method to remove from start the sms from call log, without any other further action.
I moved from that ROM to this one :WanamLite ICS UHLPS V12.2 Android 4.0.3 Stable Blue ICS & Stock Themed ...deodexed and he replaced the default option "View by - All logs" with "View by - All calls".Still not what I was looking for but is better than the stock.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 44
    There is now a new person taking over the apktool project, his name is ibotpeaches.. His apktool works with every android version up to date.. This thread will now be a basic guide on how to use apktool :)

    iBotPeaches' APKTOOL THREAD

    What I do is create a folder to work in and call it for example:
    Code:

    c:\apktools

    1) Take the apktool.jar from ibot's OP and the modded aapt he provided and place them in the folder.

    2) You will need to pull the framework-res.apk from the rom you are working on. Copy it to c:\apktools.

    4) Open a command window and navigate to your apktool folder
    cd c:\apktools

    5) We now need to install the framework and type the following:
    java -jar apktool.jar if framework-res.apk

    If you are decompiling any framework other that AOSP ie: sense, touchwiz, ect you will have to install the framework and systemui.apk for them as well, ie: for miui it's framework-miui-res.apk

    You only need to do this once, unless you are working on a different Rom, then you will need to copy the framework-res.apk from that Rom and run the above command again.

    6) We can now decompile framework-res with apktool
    java -jar apktool.jar d framework-res.apk (here you can add the folder you'd like to have your extracted apk save to)
    it will create a folder by the name of the .apk or .jar by default but say you wanted it just to go to a folder called "frameres" (just to be a lil more convienent while typing your command would look like this
    java -jar apktool.jar d framework-res.apk frameres

    the d option stands for decompile and you will now see a folder under c:\apktools\frameres (in my case, yours will be whatever your output folder's name is). Here is all the output and can make any changes you want, and then can recompile. I would test to make sure you can recompile before making a lot of changes though.


    6) We will now compile framework-res.apk
    java -jar apktool.jar b frameres NEWframework-res.apk
    I always put something different in the new apk name for instance i always put NEWapk.apk some people use numbers like apk1.apk ect.. whatever you feel is comfortable for you.. But once you enter the command it will take a few minutes and it should complete without any errors.


    7) Once it is done compiling you will need to go to c:\apktools\ and you will now see your new framework-res.apk in my case titled "NEWframework-res.apk"

    IMPORTANT LAST STEP
    Once you recompile the apk you're going to wanna use 7-zip to open both the original UNMODDED apk and the newly compiled apk
    you wanna copy the META-INF folder and the AndroidManifest.xml from the ORIGINAL into the NEWLY compiled apk otherwise your apk won't work


    Just remember to copy any apk you want to decompile right into the root of c:\apktools, run the decompile command and it will create a folder of the output that has the same of the apk file.
    4
    Thanks for the useful information! Here is an archive of batch files that simplify the process. Enough to drag needed file or folder with mouse at appropriate batch file:

    apktool-if.cmd - installation of framework-res, SystemUI, etc.
    apktool-d-1.4.2.cmd - decompiling with apktool.jar.1.4.2.
    apktool-d-1.4.3.cmd - decompiling with apktool.jar.1.4.3.
    apktool-b.cmd - building.

    Correct version of apktool is selected automatically.

    Link: ApkTools-ICS-Simple.rar
    2
    I need to update this thread.. there's a gentleman by the name of ibotpeaches who's worked his ass off continuing the apktool project.. I believe he's on 1.4.10 now.. I'll update op with link to his OP tomorrow and basic instructions to use apktool.. :)

    Sent from my SPH-D710 using Tapatalk 2
    2
    Thanks for sharing this info. I know a lot of people have been frustrated lately getting apks to properly decode and rebuild in ICS.

    I took your great instructions and refined them a bit to reduce the workflow, having to rename the apktool.jar between decoding and building. You can download what I am using here.


    • First register framework-res by placing the framework-res.apk from your rom into the extracted apktool zip directory, then execute 0-FRAMEWORK-IF.BAT:

      Code:
      C:\Test\Test1.4.2-1.4.3>0-FRAMEWORK-IF.bat
      I: Framework installed to: C:\Users\Derek\apktool\framework\1.apk
    • Next decode the apk, 1-DECODE.BAT SystemUI.apk . A new output sub-directory will automatically be created based on the apk name (SystemUI.apk_out):

      Code:
      C:\Test\Test1.4.2-1.4.3>apktool-1.4.2.bat d SystemUI.apk ./SystemUI.apk_out
      I: Baksmaling...
      I: Loading resource table...
      I: Loaded.
      I: Loading resource table from file: C:\Users\Derek\apktool\framework\1.apk
      I: Loaded.
      I: Decoding file-resources...
      I: Decoding values*/* XMLs...
      I: Done.
      I: Copying assets and libs...
    • Make your edits and build. 2-BUILD.BAT SystemUI.apk:

      Code:
      C:\Test\Test1.4.2-1.4.3>2-BUILD.bat SystemUI.apk
      
      C:\Test\Test1.4.2-1.4.3>apktool-1.4.3.bat b -f -d SystemUI.apk_out
      I: Smaling...
      I: Building resources...
      I: Building apk file...

    Download zip package
    2
    By the way, when I induce bootloop issues like this from messing with the system, I've started doing a custom Nandroid restore and just restoring the system, to save time. If anyone knows a reason not to do this, please let me know.
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone