Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

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

OP evol4g

5th July 2012, 02:08 AM   |  #1  
evol4g's Avatar
OP Senior Member
Flag chandler-gilbert 480!!!
Thanks Meter: 1,460
 
1,868 posts
Join Date:Joined: Mar 2012
Donate to Me
More
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 by evol4g; 17th September 2012 at 04:55 AM.
The Following 44 Users Say Thank You to evol4g For This Useful Post: [ View ]
5th July 2012, 03:38 AM   |  #2  
alteredlikeness's Avatar
Recognized Contributor
Flag reflecting on Indra's net
Thanks Meter: 5,400
 
2,422 posts
Join Date:Joined: Mar 2012
Donate to Me
More
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
5th July 2012, 05:07 AM   |  #3  
dreamer94's Avatar
Senior Member
Flag Ankara
Thanks Meter: 97
 
418 posts
Join Date:Joined: Jan 2012
More
Okay fully got it but download link is broken can anyone share it with us if he has?
Regards

Sent from my GT-I9000 using Tapatalk 2
5th July 2012, 05:43 AM   |  #4  
blazingwolf's Avatar
Senior Member
Thanks Meter: 402
 
2,100 posts
Join Date:Joined: Nov 2006
Donate to Me
More
Quote:
Originally Posted by dreamer94

Okay fully got it but download link is broken can anyone share it with us if he has?
Regards

Sent from my GT-I9000 using Tapatalk 2

It's working fine for me.
5th July 2012, 05:47 AM   |  #5  
evol4g's Avatar
OP Senior Member
Flag chandler-gilbert 480!!!
Thanks Meter: 1,460
 
1,868 posts
Join Date:Joined: Mar 2012
Donate to Me
More
Quote:
Originally Posted by alteredlikeness

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
5th July 2012, 05:27 PM   |  #6  
alteredlikeness's Avatar
Recognized Contributor
Flag reflecting on Indra's net
Thanks Meter: 5,400
 
2,422 posts
Join Date:Joined: Mar 2012
Donate to Me
More
Quote:
Originally Posted by evol4g

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..
The Following User Says Thank You to alteredlikeness For This Useful Post: [ View ]
5th July 2012, 11:02 PM   |  #7  
Ticklefish's Avatar
Recognized Themer
Flag UK
Thanks Meter: 3,977
 
4,277 posts
Join Date:Joined: Oct 2011
More
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.
7th July 2012, 06:29 PM   |  #8  
a-id's Avatar
Senior Member
Thanks Meter: 173
 
156 posts
Join Date:Joined: Oct 2010
Donate to Me
More
Wink
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 by a-id; 7th July 2012 at 06:54 PM.
The Following 4 Users Say Thank You to a-id For This Useful Post: [ View ]
7th July 2012, 06:39 PM   |  #9  
myn's Avatar
Senior Recognized Developer
Thanks Meter: 4,002
 
2,658 posts
Join Date:Joined: Nov 2007
Donate to Me
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
The Following 2 Users Say Thank You to myn For This Useful Post: [ View ]
7th July 2012, 06:41 PM   |  #10  
myn's Avatar
Senior Recognized Developer
Thanks Meter: 4,002
 
2,658 posts
Join Date:Joined: Nov 2007
Donate to Me
Quote:
Originally Posted by a-id

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!

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes