[team d.i.r.t] how to properly de/recompile apks on all android versions!
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
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.
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
Quote:
Originally Posted by doseone/themselves
Code:
watch your hand, the motorized lifestyle likes to bite and grind
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
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..
Quote:
Originally Posted by doseone/themselves
Code:
watch your hand, the motorized lifestyle likes to bite and grind
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.
(Signature Picture & Avatar By Yorzua's Design Factory)
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.
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):
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.
Unless you just emerged from a deep, dark, dank cavern under the Earth, you know … more
XDA Developers was founded by developers, for developers. It is now a valuable resource for people who want to make the most of their mobile devices, from customizing the look and feel to adding new functionality. Are you a developer?