[HOW TO] Compile/Decompile ICS Apk easily|100% working

Search This thread

memnoc

Inactive Recognized Developer
Feb 23, 2011
4,542
5,209
We are all here to learn, take from community and give back to community!!!
@Lord ClockaN

Hya guys, after A LOT of requests, I decided to share with the community something that I found really REALLY useful for Dev's but also for other users too that want to mess up with compiling and decompiling process. Usually, non problems at all with that, but since ICS come out, many dev\users are not able to decompile\compile properly many ics apk (not all). This guide will ensure you a good result, 100% working, easy, and fastest way to mess up with ics for theming and resizing purposes, or whatever you want;)
BIG THX to my friend and Dev teammate @Bichon for this;)

Credits
@Bichon (yes, again:))
@Xavierjohn22, the amazing author of AutoApktool! Visit his thread HERE, click his thanks button, and support his work with donations, and my personal thanks to author for this tool which is the most powerful and easiest tool ever.
@Brut_all for Apktool
@XDA Community
@Google

About Apktooll

Please consider to visit the original thread about this tool, because what I'm explaining here is just 1\10 of the real skill of this tool. You can do basically whatever you want with AutoApktool, themers will love it, Dev's will appreciate it a lot, I'm sure.

Why can't we use Apktool???

Well, you can, but it's more difficult, that's it.

Why do you say "must use 1.4.1 apktool version"??

The reason why is that since 1.4.2 version, apktool generate java code while recompiling process is going on, and this lead to errors that 9/10 makes decompile process fail.

Requirements (Windows environment, mine is Seven 64 bit)

Java (last version)
JDK (last version)
JDR (last version, usually included in JDK or Java)
SDK (last 3.0 version for ICS source code)
Auto_Apktool 2.0.0 (DOWNLOAD THIS ONE NOT OTHERS!!!)

HOW-TO (NOTE: before start, select Apktool version with option 21, YOU MUST CHOOSE 1.4.1 version!!)

1) Download and simply unpack Auto_ApkTool 2.0.0
2)Click on "autoapktoolmain.bat", prompt will open
ssofz.png

3)put the apk you want to mess up with in "_INPUT_APK"
ukg3i.png

4) you can chose more than one option to decompile (option 6 is strongly recommended)
5) when option 6 is being selected, drag the apk from _INPUT_APK folder into the windows prompt and click enter
e48e2.png

6) A Note window will appear, and will show IF the decompiling process has been done properly. Once you close that window, you will see the decompiled folder in _INPUT_APK folder
gxlkg.png

7) do your edits (xml, snali, or png, doesn't matter)
8) recompile with option 7 (NOTE: this time you MUST drag all the FOLDER, NOT the apk)
9) Once recompiling finished, open the decompiled folder, go to "dist" folder, and here you got your edited apk
tyqwv.png

10) you MUST sign the apk with option 10 (NOTE: drag the apk from dist folder to the prompt, then press enter, and in the SAME folder, a signedxxx.apk will appear)
gq266.png

11) Rename the apk, and push it |NOTE: you can push the apk with 62 option or with sdk typing:
Code:
adb remount
adb push xxx.apk system/app
adb reboot

That's it;)
 
Last edited:

memnoc

Inactive Recognized Developer
Feb 23, 2011
4,542
5,209
NOTE FOR SAMSUNG USERS

Samsung changed some Hex value in the compiled dex code.
It has nothing to do with resources apks or anthing.
If you want to decompile those apks you have to do the follwing:

Using 7zip extract the classes.dex file from the apk and save it somewhere.\
Delete the classes.dex file from the apk.
Now you can decompile the apk using this tutorial.
If you want to decompile the classes.dex to edit the smali code, download baksmali 1.3.2 and smali 1.3.2 and use them to decompile and recompile the classes.dex.
After you recompiled the edited smali code, just drag back in the new classes.dex file you made.

this won't be fixed until Brut will make a new Apktool, or someone inserted the new baksmali/smali code into apktool

THX @Firefeds

When you're in trouble...try this one, you can apply the following method to the op too
Downloads:
http://code.google.com/p/smali/downloads/list
smali/baksmali editing v1.3.2

- Download both smali and baksmali v1.3.2

http://code.google.com/p/android-apktool/downloads/list
This is the latest apktool used to compile/decompile .apk.
Download apktool1.4.3.tar.bz2 and apktool-install-windows-r04-brut1.tar.bz2 for Windows or
apktool-install-macosx-r04-brut1.tar.bz2 and apktool-install-linux-r04-brut1.tar.bz2 for Mac. Follow the instruction on installation.

Step by step:
1. Extract the classes.dex from the desired apk.
2. Decompile it with baksmali v1.3.2 (for modding smali)
3. Recompile classes.dex with smali v1.3.2.
4. Decompile the apk with apktool (without classes.dex in the apk itself).
4a. Modify the apk however you want to, adding your changes.
4b. Recompile it with apktool.
5. Put the modified apk back into classes.dex.
6. Sign the apk.


thx @djolebih
 
Last edited:

Vertumus

Inactive Recognized Themer
Sep 1, 2010
4,896
12,384
Belgrade
memoriaphotogallery.com
Great tutorial mate. As soon as I come home ill try. I am moving my theme to the ICS and I hope this works with samsung ics apps

All the best,
Vert

---------- Post added at 09:59 AM ---------- Previous post was at 09:43 AM ----------

It doesn't work with bloody samsung ics apps...

[*] C:\Users\040588\Desktop\AutoAPKTool2.0.0\_INPUT_APK\SystemUI.apk
decompiling C:\Users\040588\Desktop\AutoAPKTool2.0.0\_INPUT_APK\SystemUI.apk...
I: Baksmaling...
Exception in thread "main" java.lang.RuntimeException: bad magic value: 64 65 78 0a 30 33 36 00
at org.jf.dexlib.DexFile.<init>(DexFile.java:377)
at org.jf.dexlib.DexFile.<init>(DexFile.java:274)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:44)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:33)
at brut.androlib.Androlib.decodeSourcesSmali(Androlib.java:68)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:85)
at brut.apktool.Main.cmdDecode(Main.java:128)
at brut.apktool.Main.main(Main.java:65)
 

memnoc

Inactive Recognized Developer
Feb 23, 2011
4,542
5,209
Great tutorial mate. As soon as I come home ill try. I am moving my theme to the ICS and I hope this works with samsung ics apps

All the best,
Vert

---------- Post added at 09:59 AM ---------- Previous post was at 09:43 AM ----------

It doesn't work with bloody samsung ics apps...

[*] C:\Users\040588\Desktop\AutoAPKTool2.0.0\_INPUT_APK\SystemUI.apk
decompiling C:\Users\040588\Desktop\AutoAPKTool2.0.0\_INPUT_APK\SystemUI.apk...
I: Baksmaling...
Exception in thread "main" java.lang.RuntimeException: bad magic value: 64 65 78 0a 30 33 36 00
at org.jf.dexlib.DexFile.<init>(DexFile.java:377)
at org.jf.dexlib.DexFile.<init>(DexFile.java:274)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:44)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:33)
at brut.androlib.Androlib.decodeSourcesSmali(Androlib.java:68)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:85)
at brut.apktool.Main.cmdDecode(Main.java:128)
at brut.apktool.Main.main(Main.java:65)

mate make sure u have loaded all resources apk, then follow the errors, isn't a tool fault for what I can see...u edited some smali right?
 
B

BiCh0n

Guest
thanks for all user would mod ics apk and thanks for put my name in OP.. ;)
 

0utl4wZ

Senior Member
Nov 18, 2010
71
6
Thanks for this great tutorial memnoc.

But when you create your own app you can checkout your project in eclipse or something like this. Ive read that this is for security that your app cant be decompiled.

Will this program decompile such apk's too?
 

memnoc

Inactive Recognized Developer
Feb 23, 2011
4,542
5,209
Thanks for this great tutorial memnoc.

But when you create your own app you can checkout your project in eclipse or something like this. Ive read that this is for security that your app cant be decompiled.

Will this program decompile such apk's too?

can't follow u mate, give me an ex so i can understand what app r u talkin about
 

0utl4wZ

Senior Member
Nov 18, 2010
71
6
can't follow u mate, give me an ex so i can understand what app r u talkin about

Is there a difference between market and system app? I'm talking about normal market apps, which you can build in java with eclipse. There is a choice to publish. I don't know the right name there. With this the apk should built that you can't decompile this. (So I read it)

But if there is a difference you can decompile all system apks without problems? This would be very nice :)
 

memnoc

Inactive Recognized Developer
Feb 23, 2011
4,542
5,209
Is there a difference between market and system app? I'm talking about normal market apps, which you can build in java with eclipse. There is a choice to publish. I don't know the right name there. With this the apk should built that you can't decompile this. (So I read it)

But if there is a difference you can decompile all system apks without problems? This would be very nice :)

Guess yeah, but you should try, I don't create the tool i just posted a way to use it changing aapt and make it ready to use for you

Inviato dal mio HTC Desire HD with Beats Audio usando Tapatalk
 

agat63

Inactive Recognized Developer
Sep 14, 2010
3,987
7,937
Las Vegas, NV
mate make sure u have loaded all resources apk, then follow the errors, isn't a tool fault for what I can see...u edited some smali right?

I'm trying to decompile Contacts.apk and Phone.apk and getting same error message:

[*] C:\Android\AutoAPKTool2.0.0\_INPUT_APK\Contacts.apk
decompiling C:\Android\AutoAPKTool2.0.0\_INPUT_APK\Contacts.apk...
I: Baksmaling...
Exception in thread "main" java.lang.RuntimeException: bad magic value: 64 65 78 0a 30 33 36 00
at org.jf.dexlib.DexFile.<init>(DexFile.java:377)
at org.jf.dexlib.DexFile.<init>(DexFile.java:274)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:44)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:33)
at brut.androlib.Androlib.decodeSourcesSmali(Androlib.java:68)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:85)
at brut.apktool.Main.cmdDecode(Main.java:128)
at brut.apktool.Main.main(Main.java:65)

I had this message in ApkManager 4.9, 5.0.
Not new to themeing. Done my fair share and never had problem decompiling apps.
Did try to decompile framework-res.apk and it went through without any errors or problems. However the Contacts.apk for ICS will not decompile.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 75
    We are all here to learn, take from community and give back to community!!!
    @Lord ClockaN

    Hya guys, after A LOT of requests, I decided to share with the community something that I found really REALLY useful for Dev's but also for other users too that want to mess up with compiling and decompiling process. Usually, non problems at all with that, but since ICS come out, many dev\users are not able to decompile\compile properly many ics apk (not all). This guide will ensure you a good result, 100% working, easy, and fastest way to mess up with ics for theming and resizing purposes, or whatever you want;)
    BIG THX to my friend and Dev teammate @Bichon for this;)

    Credits
    @Bichon (yes, again:))
    @Xavierjohn22, the amazing author of AutoApktool! Visit his thread HERE, click his thanks button, and support his work with donations, and my personal thanks to author for this tool which is the most powerful and easiest tool ever.
    @Brut_all for Apktool
    @XDA Community
    @Google

    About Apktooll

    Please consider to visit the original thread about this tool, because what I'm explaining here is just 1\10 of the real skill of this tool. You can do basically whatever you want with AutoApktool, themers will love it, Dev's will appreciate it a lot, I'm sure.

    Why can't we use Apktool???

    Well, you can, but it's more difficult, that's it.

    Why do you say "must use 1.4.1 apktool version"??

    The reason why is that since 1.4.2 version, apktool generate java code while recompiling process is going on, and this lead to errors that 9/10 makes decompile process fail.

    Requirements (Windows environment, mine is Seven 64 bit)

    Java (last version)
    JDK (last version)
    JDR (last version, usually included in JDK or Java)
    SDK (last 3.0 version for ICS source code)
    Auto_Apktool 2.0.0 (DOWNLOAD THIS ONE NOT OTHERS!!!)

    HOW-TO (NOTE: before start, select Apktool version with option 21, YOU MUST CHOOSE 1.4.1 version!!)

    1) Download and simply unpack Auto_ApkTool 2.0.0
    2)Click on "autoapktoolmain.bat", prompt will open
    ssofz.png

    3)put the apk you want to mess up with in "_INPUT_APK"
    ukg3i.png

    4) you can chose more than one option to decompile (option 6 is strongly recommended)
    5) when option 6 is being selected, drag the apk from _INPUT_APK folder into the windows prompt and click enter
    e48e2.png

    6) A Note window will appear, and will show IF the decompiling process has been done properly. Once you close that window, you will see the decompiled folder in _INPUT_APK folder
    gxlkg.png

    7) do your edits (xml, snali, or png, doesn't matter)
    8) recompile with option 7 (NOTE: this time you MUST drag all the FOLDER, NOT the apk)
    9) Once recompiling finished, open the decompiled folder, go to "dist" folder, and here you got your edited apk
    tyqwv.png

    10) you MUST sign the apk with option 10 (NOTE: drag the apk from dist folder to the prompt, then press enter, and in the SAME folder, a signedxxx.apk will appear)
    gq266.png

    11) Rename the apk, and push it |NOTE: you can push the apk with 62 option or with sdk typing:
    Code:
    adb remount
    adb push xxx.apk system/app
    adb reboot

    That's it;)
    22
    NOTE FOR SAMSUNG USERS

    Samsung changed some Hex value in the compiled dex code.
    It has nothing to do with resources apks or anthing.
    If you want to decompile those apks you have to do the follwing:

    Using 7zip extract the classes.dex file from the apk and save it somewhere.\
    Delete the classes.dex file from the apk.
    Now you can decompile the apk using this tutorial.
    If you want to decompile the classes.dex to edit the smali code, download baksmali 1.3.2 and smali 1.3.2 and use them to decompile and recompile the classes.dex.
    After you recompiled the edited smali code, just drag back in the new classes.dex file you made.

    this won't be fixed until Brut will make a new Apktool, or someone inserted the new baksmali/smali code into apktool

    THX @Firefeds

    When you're in trouble...try this one, you can apply the following method to the op too
    Downloads:
    http://code.google.com/p/smali/downloads/list
    smali/baksmali editing v1.3.2

    - Download both smali and baksmali v1.3.2

    http://code.google.com/p/android-apktool/downloads/list
    This is the latest apktool used to compile/decompile .apk.
    Download apktool1.4.3.tar.bz2 and apktool-install-windows-r04-brut1.tar.bz2 for Windows or
    apktool-install-macosx-r04-brut1.tar.bz2 and apktool-install-linux-r04-brut1.tar.bz2 for Mac. Follow the instruction on installation.

    Step by step:
    1. Extract the classes.dex from the desired apk.
    2. Decompile it with baksmali v1.3.2 (for modding smali)
    3. Recompile classes.dex with smali v1.3.2.
    4. Decompile the apk with apktool (without classes.dex in the apk itself).
    4a. Modify the apk however you want to, adding your changes.
    4b. Recompile it with apktool.
    5. Put the modified apk back into classes.dex.
    6. Sign the apk.


    thx @djolebih
    9
    Great tutorial mate. As soon as I come home ill try. I am moving my theme to the ICS and I hope this works with samsung ics apps

    All the best,
    Vert

    ---------- Post added at 09:59 AM ---------- Previous post was at 09:43 AM ----------

    It doesn't work with bloody samsung ics apps...

    [*] C:\Users\040588\Desktop\AutoAPKTool2.0.0\_INPUT_APK\SystemUI.apk
    decompiling C:\Users\040588\Desktop\AutoAPKTool2.0.0\_INPUT_APK\SystemUI.apk...
    I: Baksmaling...
    Exception in thread "main" java.lang.RuntimeException: bad magic value: 64 65 78 0a 30 33 36 00
    at org.jf.dexlib.DexFile.<init>(DexFile.java:377)
    at org.jf.dexlib.DexFile.<init>(DexFile.java:274)
    at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:44)
    at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:33)
    at brut.androlib.Androlib.decodeSourcesSmali(Androlib.java:68)
    at brut.androlib.ApkDecoder.decode(ApkDecoder.java:85)
    at brut.apktool.Main.cmdDecode(Main.java:128)
    at brut.apktool.Main.main(Main.java:65)

    Samsung changed some Hex value in the compiled dex code.
    It has nothing to do with resources apks or anthing.
    If you want to decompile those apks you have to do the follwing:

    Using 7zip extract the classes.dex file from the apk and save it somewhere.\
    Delete the classes.dex file from the apk.
    Now you can decompile the apk using this tutorial.
    If you want to decompile the classes.dex to edit the smali code, download baksmali 1.3.2 and smali 1.3.2 and use them to decompile and recompile the classes.dex.
    After you recompiled the edited smali code, just drag back in the new classes.dex file you made.

    this won't be fixed until Brut will make a new Apktool, or someone inserted the new baksmali/smali code into apktool
    3
    Very good information.Thanks!
    3

    Thx my friend, I have a great team behind the scene;)