[Share Latest Apktool 4.2.2/Guide/Tutorial/] How to Decompile/Compile/Sign Apk/Jar

Search This thread

Rizal Lovins

Recognized Developer / Themer / Inactive RC
May 30, 2012
1,617
15,944
Bandung
LG V30
How to Decompile, Recompile & Sign apk

This Guide/Tutorial for Windows user

Requirement :

1. Android SDK, you can download from here (this including Java)
2. Download Latest Apktool 4.2.2 (Including Sign & baksmali) from here (this Support All apk from GB/ICS/JB 4.1.2/4.2.2)
3. Notepad++ for your tool editing xml/smali you can download from here

If you already download/Installed Android sdk/java & Notepadd++ you just download Latest Apktool 4.2.2


Download Latest Apktool, extract to :

Windows XP : C:\Document and setting\folder your computer name

Windows 7 : C:\user\folder your computer name

copy your apk & framework-res.apk/SemcGenericUxpRes.apk/framework 2 to same folder with apktool

Now you can start Editing apk

Example Editing Walkman

Open Command Prompt (CMD)

to decompile :

Code:
apktool if framework-res.apk
apktool d semcmusic.apk ( can be whatever name you give to your apk )

Some Original system apps need installed framework 2 like on stock ROM (SemcGenericUxpRes.apk)

Example

Code:
apktool if framework-res.apk
apktool if semcgenericuxpres.apk
apktool d semcmusic.apk ( can be whatever name you give to your apk )

You can start editing as you want ;)


to recompile :

Code:
apktool b -f -d semcmusic.apk ( can be whatever name you give to your apk )

If done, you can exit CMD

open original SemcMusic.apk using Winrar or 7zip go to folder semcmusic>dist, open semcmusic.apk using Winrar or 7zip

Drag & drop folder META-INF & Lib in original apk to Modified apk, set compression to store and click ok

to sign :

Move apk modified from folder semcmusic>dist to same folder with apktool

Open Command Prompt (CMD)

Example

Code:
java -jar SignApk.jar testkey.x509.pem testkey.pk8 semcmusic.apk semcmusic_signed.apk ( can be whatever name you give to your apk )

NOTE : Sign apk only for apps 3rd Party but you can use for system>app but not all apps

to zipalign :

Open Command Prompt (CMD)

Example

Code:
zipalign -fv 4 semcmusic_signed.apk semcmusic_signed_zipaligned.apk
 
Last edited:

Rizal Lovins

Recognized Developer / Themer / Inactive RC
May 30, 2012
1,617
15,944
Bandung
LG V30
How to Decompile/Recompile Jar/Editing classes.dex

Copy Jar file to same folder Apktool

Example

framework.jar

to decompile :

Open framework.jar using Winrar or 7zip and extract classes.dex

Drag & drop classes.dex to Quick-Baksmali (CMD)

if done, you can find folder classes-out

now you can start editing smali file using Notepad++


to recompile :

Drag & drop folder classes-out to Quick-Smali (CMD)

if done, you can find New file "new-classes.dex"

rename file to classes.dex

Open framework.jar using Winrar or 7zip

Drag & drop file classes.dex modified to framework.jar using Winrar or 7zip set compression to normal
 
Last edited:

Rajeev

Recognized Contributor
Nov 24, 2012
16,298
26,531
Chennai , I N D I A
No doubt.. Its a great guide for some one like me.... Will sit today night and going to learn.... Thanks a lot..

From My Xperia S With XTX7 ROM
 

m1st3r1

Senior Member
Aug 15, 2010
890
279
Jakarta
Great guide Rizal. Decent English too. Lol. Proud to be Sundanese..

In my opinion, there are other more simplified tools that utilized apktool better (I use apkmultitools and vts (virtuous ten studios)) but people needs to know the basic right..

And I think, you need to put the java\bin directory in Path in windows system variables (or Java_home in win8). And it's better (I think) to put sdk directory (adb, fastboot), apktool and the smali jars files in the Path too, so that users can access from any folders/directory.

Sent from my LT26i using Tapatalk 2
 

Rizal Lovins

Recognized Developer / Themer / Inactive RC
May 30, 2012
1,617
15,944
Bandung
LG V30
now bookmark it!! thanks dude!! :good:

:thumbup:



Thanks for the credits, buddy
nice share there :cowboy:

Thanks for your support my friend


Great guide Rizal. Decent English too. Lol. Proud to be Sundanese..

In my opinion, there are other more simplified tools that utilized apktool better (I use apkmultitools and vts (virtuous ten studios)) but people needs to know the basic right..

And I think, you need to put the java\bin directory in Path in windows system variables (or Java_home in win8). And it's better (I think) to put sdk directory (adb, fastboot), apktool and the smali jars files in the Path too, so that users can access from any folders/directory.

Sent from my LT26i using Tapatalk 2

Yeah I know, but some user will confusing lolz, this apktool is latest version so will work for apk 4.2.2, old version doesn't work

:thumbup:

Sent from my Xperia V using Tapatalk 2
 

m1st3r1

Senior Member
Aug 15, 2010
890
279
Jakarta
Hey rizal, following your decmpile/recompile method, the apk wont install, signature problem.
There are some problems when signing the apk. The workaround for this: use some tools (ticklemyandroid does good jobs) to completely signing the apk (I've done this when modifying systemui.apk), you can also learn from it (learn some of its codes). Or just move files that u've modified from the modified (recompiled) apk to original apk (7zip is your friend)


I've seen other guides say that resources.arsc should be copied from the old apk and stored in the new one.... is that necessary?
I don't think it's necessary. But keep in my mind my post above. So it's like u keep the old resource but put the modified (and compiled) files to the original.

Sent from my LT26i using Tapatalk 2
 

zhuhang

Inactive Recognized Contributor
Apr 3, 2011
4,136
14,591
Petaling Jaya
www.facebook.com
There are some problems when signing the apk. The workaround for this: use some tools (ticklemyandroid does good jobs) to completely signing the apk (I've done this when modifying systemui.apk), you can also learn from it (learn some of its codes). Or just move files that u've modified from the modified (recompiled) apk to original apk (7zip is your friend)
Just moving with normal compression?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 172
    How to Decompile, Recompile & Sign apk

    This Guide/Tutorial for Windows user

    Requirement :

    1. Android SDK, you can download from here (this including Java)
    2. Download Latest Apktool 4.2.2 (Including Sign & baksmali) from here (this Support All apk from GB/ICS/JB 4.1.2/4.2.2)
    3. Notepad++ for your tool editing xml/smali you can download from here

    If you already download/Installed Android sdk/java & Notepadd++ you just download Latest Apktool 4.2.2


    Download Latest Apktool, extract to :

    Windows XP : C:\Document and setting\folder your computer name

    Windows 7 : C:\user\folder your computer name

    copy your apk & framework-res.apk/SemcGenericUxpRes.apk/framework 2 to same folder with apktool

    Now you can start Editing apk

    Example Editing Walkman

    Open Command Prompt (CMD)

    to decompile :

    Code:
    apktool if framework-res.apk
    apktool d semcmusic.apk ( can be whatever name you give to your apk )

    Some Original system apps need installed framework 2 like on stock ROM (SemcGenericUxpRes.apk)

    Example

    Code:
    apktool if framework-res.apk
    apktool if semcgenericuxpres.apk
    apktool d semcmusic.apk ( can be whatever name you give to your apk )

    You can start editing as you want ;)


    to recompile :

    Code:
    apktool b -f -d semcmusic.apk ( can be whatever name you give to your apk )

    If done, you can exit CMD

    open original SemcMusic.apk using Winrar or 7zip go to folder semcmusic>dist, open semcmusic.apk using Winrar or 7zip

    Drag & drop folder META-INF & Lib in original apk to Modified apk, set compression to store and click ok

    to sign :

    Move apk modified from folder semcmusic>dist to same folder with apktool

    Open Command Prompt (CMD)

    Example

    Code:
    java -jar SignApk.jar testkey.x509.pem testkey.pk8 semcmusic.apk semcmusic_signed.apk ( can be whatever name you give to your apk )

    NOTE : Sign apk only for apps 3rd Party but you can use for system>app but not all apps

    to zipalign :

    Open Command Prompt (CMD)

    Example

    Code:
    zipalign -fv 4 semcmusic_signed.apk semcmusic_signed_zipaligned.apk
    51
    How to Decompile/Recompile Jar/Editing classes.dex

    Copy Jar file to same folder Apktool

    Example

    framework.jar

    to decompile :

    Open framework.jar using Winrar or 7zip and extract classes.dex

    Drag & drop classes.dex to Quick-Baksmali (CMD)

    if done, you can find folder classes-out

    now you can start editing smali file using Notepad++


    to recompile :

    Drag & drop folder classes-out to Quick-Smali (CMD)

    if done, you can find New file "new-classes.dex"

    rename file to classes.dex

    Open framework.jar using Winrar or 7zip

    Drag & drop file classes.dex modified to framework.jar using Winrar or 7zip set compression to normal
    17
    Credits :

    Thanks to Brut.all for apktool
    Thanks to Yorzua for Sign apk tool/file
    Thanks to Team Reject for Quick baksmali/smali file


    NOTE : If you get error when compiling, don't blame me lolz :p it's your mistake when editing apk
    3
    Great Guide Rizal. I am sure many were asking for it.
    2
    Hello Everybody,
    i get this when i recompile SystemUI after editing

    Code:
    C:\APKTOOL>apktool b -f -d SystemUI
    I: Smaling...
    I: Building resources...
    Warning: AndroidManifest.xml already defines minSdkVersion (in http://schemas.an
    droid.com/apk/res/android); using existing value in manifest.
    Warning: AndroidManifest.xml already defines targetSdkVersion (in http://schemas
    .android.com/apk/res/android); using existing value in manifest.
    I: Building apk file...

    But I just don't get any apk at the end!:(
    Any help would be appreciable!

    These are just warnings. nothing serious.
    When you decompiled your SystemUI.apk, a folder (named SystemUI) was created.
    After recompiling your SystemUI.apk, the file will be placed in \SystemUI\dist\

    ---------- Post added at 12:44 PM ---------- Previous post was at 12:05 PM ----------

    I AM ALWAYS CONFUSED IN SIGNING. I JUST DID EVERYTHING AS IT IS BUT CONFUSED IN REPLACING FILES FROM OLDER APK TO MODIFIED APK :crying: i saw many posts. somebody says copy META-INF folder. somebody says copy META-INF and androidmainfest.xml but when i open older apk there is 4 files i see
    1. META-INF
    2. AndroidMainfest.xml
    3. classes.dex
    4. resources.arsc

    please somebody tell me that what really i have to do :(:(:(:(:(:(:(:(:(

    Quite simple. You copy the META-INF-Folder AND the Androidmanifest.xml from the original APK to your newly compiled APK.