Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,770,879 Members 43,519 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
evol4g
Old
(Last edited by evol4g; 17th September 2012 at 03:55 AM.)
#1  
evol4g's Avatar
Senior Member - OP
Thanks Meter 1451
Posts: 1,822
Join Date: Mar 2012
Location: chandler-gilbert 480!!!

 
DONATE TO ME
Default [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

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.


HTC ONE S ROMS
Xylon | SlimBean | DirtyUnicorns

ADDED A DONATE BUTTON! feel free to contribute
The Following 44 Users Say Thank You to evol4g For This Useful Post: [ Click to Expand ]
 
alteredlikeness
Old
#2  
alteredlikeness's Avatar
Recognized Contributor
Thanks Meter 5185
Posts: 2,393
Join Date: Mar 2012
Location: reflecting on Indra's net

 
DONATE TO ME
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 View Post
Code:
Select Code
...with the kind of hunger wings once sprung from...
A2 Edison | N10 Manta | One M8


/-\ |_ T F |2 F |)
 
dreamer94
Old
#3  
dreamer94's Avatar
Senior Member
Thanks Meter 94
Posts: 405
Join Date: Jan 2012
Location: Ankara
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
Life is a joke. Deal with it.
Nexus 4 Black (Rev11 / 311K)
Nexus 5 Red (407K)
 
blazingwolf
Old
#4  
blazingwolf's Avatar
Senior Member
Thanks Meter 401
Posts: 2,101
Join Date: Nov 2006

 
DONATE TO ME
Quote:
Originally Posted by dreamer94 View Post
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.
Verizon Samsung Galaxy S4 (Rooted NC5), Nook HD (CM11)

In fire and EMS? Check out my apps on Google Play Pumper Calc and Code Log.
 
evol4g
Old
#5  
evol4g's Avatar
Senior Member - OP
Thanks Meter 1451
Posts: 1,822
Join Date: Mar 2012
Location: chandler-gilbert 480!!!

 
DONATE TO ME
Quote:
Originally Posted by alteredlikeness View Post
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


HTC ONE S ROMS
Xylon | SlimBean | DirtyUnicorns

ADDED A DONATE BUTTON! feel free to contribute
 
alteredlikeness
Old
#6  
alteredlikeness's Avatar
Recognized Contributor
Thanks Meter 5185
Posts: 2,393
Join Date: Mar 2012
Location: reflecting on Indra's net

 
DONATE TO ME
Quote:
Originally Posted by evol4g View Post
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 View Post
Code:
Select Code
...with the kind of hunger wings once sprung from...
A2 Edison | N10 Manta | One M8


/-\ |_ T F |2 F |)
The Following User Says Thank You to alteredlikeness For This Useful Post: [ Click to Expand ]
 
Ticklefish
Old
#7  
Ticklefish's Avatar
Recognized Themer
Thanks Meter 3235
Posts: 3,679
Join Date: Oct 2011
Location: 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.


- Tickle My Android 9.1 -

Making Theming Android Fun!


Decompile Files, Change Icons, Change Fonts,
Change Boot Animations, Create Flashable Zips, Deodex Roms
..And More!


http://forum.xda-developers.com/showthread.php?t=1633333
 
a-id
Old
(Last edited by a-id; 7th July 2012 at 05:54 PM.)
#8  
a-id's Avatar
Senior Member
Thanks Meter 166
Posts: 145
Join Date: Oct 2010

 
DONATE TO ME
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


GT-I9000 (16Gb) + Optimum JellyBean by Likeman (Semaphore kernel)

a-id = Likeman

Sorry for my English, it's not my native language... :P
The Following 4 Users Say Thank You to a-id For This Useful Post: [ Click to Expand ]
 
myn
Old
#9  
myn's Avatar
Senior Recognized Developer
Thanks Meter 4002
Posts: 2,658
Join Date: 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: [ Click to Expand ]
 
myn
Old
#10  
myn's Avatar
Senior Recognized Developer
Thanks Meter 4002
Posts: 2,658
Join Date: Nov 2007

 
DONATE TO ME
Quote:
Originally Posted by a-id View Post
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!

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes