[HowTo]Decompile/Compile APKS on Windows

Chris_84

Senior Member
Feb 5, 2011
3,783
5,052
0
37
Ingolstadt
Hey Guys ,

I am writing this small guide for people who have just started off with Android Development recently..
as am not a great developer at my end so any corrections and suggestions are always welcome :)


Credits : To Vegeta1. He give me the idea and helped me patiently with every question i got to finish this!
To my great Omega Team Mates! You guys and girl know my feelings. :)



So here we gonna learn how to decompile/recompile/ sign Apks :)

Things needed :

1. jdk/java Get It from here--> http://www.java.com/en/

2. Apktool: Using any according to your liking is ok or you can get all the Stuff needed In this Link

http://forum.xda-developers.com/showthread.php?t=1755243

Thanks To iBotPeaches For The Superb Tool...

3. Notepad++ to make changes in Xmls

4: winrar/7zip


So first up we are gonna set up the Framework for the current Firmware we are using.

For that get framework-res.apk, twframework-res.apk from your rom. You can always find that in the root location

/system/framework/

So lets say you have placed your apktool in your C:\ drive

now open click on start > run > type cmd ( this is for command prompt )

for example you are on C:\>User. Click in the command line cd.. and hit enter.

You should see now C:\>, as next step you type cd apktool and click enter. Here you see how it should look:

C:\apktool>


Now first up installing framework-res.apk and twframework-res.apk.

Place both these Files in your apktool folder that you have placed in C Drive or any drive you are comfortable with.

Code for Installing frameworks :

C:\apktool>apktool if framework-res.apk
C:\apktool>apktool if twframework-res.apk

this will get both your frameworks installed .

Now decompiling the Apk ...

Lets say you want to decompile SecMms.apk / or any Apk you like

place the Apk in the apktool folder.

Code to decompile the apk:

C:\ apktool > apktool d SecMms.apk

If you done and set up things accordingly your Apks will be decompiled properly

in the apktool folder you have placed in C:\ apktool

you will get the decompiled SecMms folder... so you can now make changes to it :)

Now the Recompiling Part:

If you have made correct changes it won´t give you any issues :

To recompile the apk the code needed in the command prompt :

c:\ apktool>apktool b SecMms ( its the decompiled Folder , now the original apk )

when you are done with recompiling in the SecMms folder you will get these :

assets
build
dist
res
smali
AndroidManifest.xml
apktool.yml


Now again , if the changes you made are correct the recompiling wont give any issues :)

Now its still not over we need to sign the apk:

So in your apktool folder you have your Original SecMms.apk file open that with winrar/7zip
and extract

META-INF
AndroidManifest.xml


in the apktool folder and move them to

( Decompiled )SecMms > build > apk >

then again start cmd and again run the recompiling code again one more time

c:\ apktool > apktool b SecMms

this should sign your apk

and the final apk , you will find it in c:\apktool\SecMms\Dist\

.

So Guys that's about it , for decompiling/recompiling/signing your Apks , hope you have no issues and find my post helpful :)
 
Last edited:

Ninolina

Senior Member
Dec 1, 2009
1,432
1,191
143
Beograd
Hey Guys ,

I am writing this small guide for people who have just started off with Android Development recently..
as am not a great developer at my end so any corrections and suggestions are always welcome :)


Credits : To Vegeta1. He give me the idea and helped me patiently with every question i got to finish this!
To my great Omega Team Mates! You guys and girl know my feelings. :)



So here we gonna learn how to decompile/recompile/ sign Apks :)

Things needed :

1. jdk/java Get It from here--> http://www.java.com/en/

2. Apktool: Using any according to your liking is ok or you can get all the Stuff needed In this Link

http://forum.xda-developers.com/showthread.php?t=1755243

Thanks To iBotPeaches For The Superb Tool...

3. Notepad++ to make changes in Xmls

4: winrar/7zip


So first up we are gonna set up the Framework for the current Firmware we are using.

For that get framework-res.apk, twframework-res.apk from your rom. You can always find that in the root location

/system/framework/

So lets say you have placed your apktool in your C:\ drive

now open click on start > run > type cmd ( this is for command prompt )

for example you are on C:\>User. Click in the command line cd.. and hit enter.

You should see now C:\>, as next step you type cd apktool and click enter. Here you see how it should look:

C:\apktool>


Now first up installing framework-res.apk and twframework-res.apk.

Place both these Files in your apktool folder that you have placed in C Drive or any drive you are comfortable with.

Code for Installing frameworks :

C:\apktool>apktool if framework-res.apk
C:\apktool>apktool if twframework-res.apk

this will get both your frameworks installed .

Now decompiling the Apk ...

Lets say you want to decompile SecMms.apk / or any Apk you like

place the Apk in the apktool folder.

Code to decompile the apk:

C:\ apktool > apktool d SecMms.apk

If you done and set up things accordingly your Apks will be decompiled properly

in the apktool folder you have placed in C:\ apktool

you will get the decompiled SecMms folder... so you can now make changes to it :)

Now the Recompiling Part:

If you have made correct changes it won´t give you any issues :

To recompile the apk the code needed in the command prompt :

c:\ apktool>apktool b SecMms ( its the decompiled Folder , now the original apk )

when you are done with recompiling in the SecMms folder you will get these :

assets
build
dist
res
smali
AndroidManifest.xml
apktool.yml


Now again , if the changes you made are correct the recompiling wont give any issues :)

Now its still not over we need to sign the apk:

So in your apktool folder you have your Original SecMms.apk file open that with winrar/7zip
and extract

META-INF
AndroidManifest.xml


in the apktool folder and move them to

( Decompiled )SecMms > build > apk >

then again start cmd and again run the recompiling code again one more time

c:\ apktool > apktool b SecMms

this should sign your apk

and the final apk , you will find it in c:\apktool\SecMms\Dist\

.

So Guys that's about it , for decompiling/recompiling/signing your Apks , hope you have no issues and find my post helpful :)
Great guide Chris...:) I will try it tomorrow...:) Thanks for all you do for S3 and Omega community...:)
 
  • Like
Reactions: Chris_84

Chris_84

Senior Member
Feb 5, 2011
3,783
5,052
0
37
Ingolstadt
Really glad to be a part of a great team and great team members ....

Good luck my friend :)

Sent from my GT-I9300 using Tapatalk 2
Without you my friend I never had come this far!





This is great, you are bringing noobs like me to the next level.

Sent from my GT-I9300 using Tapatalk 2
So you're now a advanced noob. :D

Throwing out of the window from my flying Ferrari killer S3 driven by a proud omega team member :p
 
  • Like
Reactions: KeesStolk

MMWolverine

Inactive Recognized Contributor
Sep 12, 2012
1,953
4,504
153
Hey Chris! Really nice guide you have here, quick & simple. Decompiling worked for me, however, when I try to compile back I get this:
D:\apktool1.5.0>java -jar apktool.jar d BW.apk
I: Baksmaling...
I: Loading resource table...
I: Loaded.
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\MM\apktool\framework\1.apk
I: Loaded.
I: Decoding file-resources...
W: Cant find 9patch chunk in file: "drawable-hdpi/forecast_fly_child_bg_pressed.
9.png". Renaming it to *.png.
I: Decoding values */* XMLs...
I: Done.
I: Copying assets and libs...

D:\apktool1.5.0>java -jar apktool.jar b BW
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...
invalid resource directory name: D:\apktool1.5.0\BW\res/drawable-land-xhdpi
invalid resource directory name: D:\apktool1.5.0\BW\res/drawable-xhdpi
invalid resource directory name: D:\apktool1.5.0\BW\res/drawable-xhdpi-v11
invalid resource directory name: D:\apktool1.5.0\BW\res/drawable-xxhdpi
invalid resource directory name: D:\apktool1.5.0\BW\res/layout-xlarge
invalid resource directory name: D:\apktool1.5.0\BW\res/layout-xlarge-land
invalid resource directory name: D:\apktool1.5.0\BW\res/values-sw600dp
invalid resource directory name: D:\apktool1.5.0\BW\res/values-w360dp
invalid resource directory name: D:\apktool1.5.0\BW\res/values-w480dp
invalid resource directory name: D:\apktool1.5.0\BW\res/values-w500dp
invalid resource directory name: D:\apktool1.5.0\BW\res/values-w600dp
invalid resource directory name: D:\apktool1.5.0\BW\res/values-xlarge
invalid resource directory name: D:\apktool1.5.0\BW\res/values-xlarge-land
Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutExce
ption: could not exec command: [aapt, p, --min-sdk-version, 8, --target-sdk-vers
ion, 17, -F, C:\Users\MM\AppData\Local\Temp\APKTOOL3965827226790767193.tmp, -I,
C:\Users\MM\apktool\framework\1.apk, -S, D:\apktool1.5.0\BW\res, -M, D:\apktool1
.5.0\BW\AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
a:255)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:324)
at brut.androlib.Androlib.buildResources(Androlib.java:269)
at brut.androlib.Androlib.build(Androlib.java:192)
at brut.androlib.Androlib.build(Androlib.java:174)
at brut.apktool.Main.cmdBuild(Main.java:188)
at brut.apktool.Main.main(Main.java:70)
Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-sd
k-version, 8, --target-sdk-version, 17, -F, C:\Users\MM\AppData\Local\Temp\APKTO
OL3965827226790767193.tmp, -I, C:\Users\MM\apktool\framework\1.apk, -S, D:\apkto
ol1.5.0\BW\res, -M, D:\apktool1.5.0\BW\AndroidManifest.xml]
at brut.util.OS.exec(OS.java:83)
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
a:253)
... 6 more
I installed both frameworks & updated java, tried from both hdd partitions. Then I tried a different apktool version, happens again. Do you have any idea what could be the reason for this? Maybe the fact I have 2 java versions installed (v5.0 update 12 & v7 update 10).
 

Chris_84

Senior Member
Feb 5, 2011
3,783
5,052
0
37
Ingolstadt
Hey Chris! Really nice guide you have here, quick & simple. Decompiling worked for me, however, when I try to compile back I get this:

I installed both frameworks & updated java, tried from both hdd partitions. Then I tried a different apktool version, happens again. Do you have any idea what could be the reason for this? Maybe the fact I have 2 java versions installed (v5.0 update 12 & v7 update 10).
I could only imagine that is not compatible this the framework you use. I get the same yesterday then I was trying recompile again Google plus. Decompile no problem but recompile give me error. Sounds a little bit crazy but what you can try is decompile with stock framework and recompile it with the one from omega or try it the other way decompile with omegas framework and recompile with stock framework. But between the steps you got install the framework new.

Throwing out of the window from my flying Ferrari killer S3 driven by a proud omega team member :p
 
  • Like
Reactions: MMWolverine

MMWolverine

Inactive Recognized Contributor
Sep 12, 2012
1,953
4,504
153
Ok, tried with XXELL5 stock framework and tested some others as well, but no luck I'm afraid. The app is BeautifulWidgets, which I'm trying to translate into Slovenian language. The problem is I cannot even recompile unchanged folders/files, let alone changing strings.xml. So the pursue for a solution continues.
 

Chris_84

Senior Member
Feb 5, 2011
3,783
5,052
0
37
Ingolstadt
Ok, tried with XXELL5 stock framework and tested some others as well, but no luck I'm afraid. The app is BeautifulWidgets, which I'm trying to translate into Slovenian language. The problem is I cannot even recompile unchanged folders/files, let alone changing strings.xml. So the pursue for a solution continues.
That's very strange. I will take look at that cause I even turned on my laptop. Will keep you informed.

Edit: Mate I checked it. And I also fail. The strange thing is I got also an older apk from version 4 of beautiful widgets and had no problem with it. Then I checked the newer version 5 and then the failure set in. I tried to take the files like android manifest from the older apk but still fail.

Throwing out of the window from my flying Ferrari killer S3 driven by a proud omega team member :p
 
Last edited:
  • Like
Reactions: MMWolverine