[HOW TO] Use Apktool

Search This thread

v6ser

Senior Member
Jan 16, 2012
176
221
Rome before, Brasilia now
So, here i'm again porting a tutorial based on DSM_'s Tut :p

What do you need:
JRE (Java Runtime Environment)
MOD EDIT: Download Removed.

Install:

Windows:
MOD EDIT: Download Removed.
MOD EDIT: Download Removed.
Unpack both pakages you will get three files, copy those files to your Windows directory i.e. C:\WINDOWS

Decoding files:
Open Command. Run>cmd
Type-
Quote
apktool d file.apk [directory]
Example - apktool d D:\nfsshift.apk D:\nfsshift
Done!
2cb75a6e1d9197197a14ac63c8d136558abcc3440521a403287e1d3f2764ee906g.jpg


FrameworkFiles

Apktool needs the framework files to decode and build apks.

Standard framework is embedded into apktool, so you don't need to do anything for most apk files. But some manufacturers, for example Samsung, add their own framework files and use them in system apps. To use apktool against such apps, you must pull framework from a device and install/register it to apktool.

For Example, you want to decode TouchWizLauncher.apk from Android v2.2 of Galaxy 5. If you try to do that, you will get an error message:
3d0a604c39d930977d46081df02b7cb857c1c1b2cab72b32172f6ba91450d3f56g.jpg


You need to install framework in apktool Type-

apktool if [framework location]


I have the got the framework-res.apk & twframework-res.apk by extracting the ROM. You can also copy it from your phone. But take care you must copy framework.apk from that ROM in which you got the Application file.

bcc1201522b5a649ac783b00b32e631e3f6ac5bcd628d21629ee339321c7708c6g.jpg



Then try again
a053e9fbaa0bded3b7244dc262c6198c3f37a6fc3ab84e253090af9b404641636g.jpg


Now is working.


How to build decoded files:
Just type

apktool b [directory in which you have decoded the files]
Example - apktool b D:\nfsshift
Done!
244bedf181e890220ea49c4422a3c4e0310c404b68afba7b23872826443006c26g.jpg



You will find the apk file inside the decoded directory, like I found it in - D:\nfsshift\dist\nfsshift.apk

Now you need to sign your APK file.


How to Sign APK files:


When publishing an application or a custom rom you need to sign the .apk or .zip files with a certificate using a private key. The Android system uses the certificate to identify the author of an application and establish trust relationship between applications. The classic way of doing this was to use keytool then sign it with jarsigner. In this tutorial i’ll explain an alternative method which is relatively easy to use for most people using a tool called SignApk.jar.

First download the SignAPK toolMOD EDIT: Download Removed.
Extract them to a directory you will remember. I have put them in C:\SignApk

Now just open cmd and type -
Quote

cd C:\SignApk
java -jar signapk.jar certificate.pem key.pk8 your-app.apk your-app-signed.apk
Example - java -jar signapk.jar certificate.pem key.pk8 D:\nfsshift\dist\nfsshift.apk D:\nfsshift\dist\nfsshift-signed.apk

05d99cd24c230bc0cc51cad2eee53b61240d5267f2a85c1c2005d7d304833f5b6g.jpg


Your APK is signed and can be installed.
 
Last edited by a moderator:

Theonewithideas

Senior Member
Oct 21, 2011
337
62
Why I get errors when trying to decode some apk's from Xperia S? Apk's are okay, working on phone. Decompiling works on other apps.

I've registered framework-res.apk from my phone.
 

Aarush

Senior Member
Jan 11, 2012
1,497
693
New Delhi
i decompiled defaulthemes.apk from my Xperia neo v
now when i compile it again .. do i need to sign it? its a system apk!

and i am not able to build decode files( it means compiling right?).. please help!
 
Last edited:

Theonewithideas

Senior Member
Oct 21, 2011
337
62
i decompiled defaulthemes.apk from my Xperia neo v
now when i compile it again .. do i need to sign it? its a system apk!

and i am not able to build decode files( it means compiling right?).. please help!

I think you need to replace it manually first time. But make a backup, just in case.

---------- Post added at 10:43 PM ---------- Previous post was at 10:18 PM ----------

I've decoded the system app (from Xperia S) (after registering the 2 framework files)
Edited the code inside. Compiled. Signed. But when I want to install it it gives me error. The usual icon doesn't show up either.

Is the error caused by changing something in code? I've only edited some TextSize values.
 

Aarush

Senior Member
Jan 11, 2012
1,497
693
New Delhi
I think you need to replace it manually first time. But make a backup, just in case.

---------- Post added at 10:43 PM ---------- Previous post was at 10:18 PM ----------

I've decoded the system app (from Xperia S) (after registering the 2 framework files)
Edited the code inside. Compiled. Signed. But when I want to install it it gives me error. The usual icon doesn't show up either.

Is the error caused by changing something in code? I've only edited some TextSize values.

Can be with codes
Are u signing it.? Dont sign it if its a system apk

Sent from my Xperia neo V using SwiftKey!
 

mekanismen

Senior Member
Nov 20, 2011
342
344
Los Angeles
Why shouldn't you sign a system apk? I see people stating this everywhere, never any reason as to why though.

Basically, if I mess with a system apk I should just build it and then it's ready to adb push to /system/app/?
 

goldiecalypso

Senior Member
Jan 30, 2012
202
42
I've done all your steps but...

@hyztname

hi, how are you

I've done what you said in post #1 step by step, everything's ok with no error but when I push my new edited "SystemUI.apk" to the device, it doesn't work. I have the same issue when I use APKMultiTool

what do you think?
 

cowsquad

Senior Member
Aug 31, 2009
1,383
323
Portland, Oregon
OnePlus 9 Pro
@hyztname

hi, how are you

I've done what you said in post #1 step by step, everything's ok with no error but when I push my new edited "SystemUI.apk" to the device, it doesn't work. I have the same issue when I use APKMultiTool

what do you think?

You have to sign ur new app. Google how to sign apks in google :)

Sent from my Droid using Tapatalk 2
 

droidxpert

Senior Member
Jan 21, 2012
199
27
calicut
sir i decompiled framework-res.apk and i have modded the pngs in drawable ldpi folder.but when i am trying to recompile it it shows errors in every png i modded..i modded using photoshop cs6...please help
 

droidxpert

Senior Member
Jan 21, 2012
199
27
calicut
ya i was editing .9 pngs.and one of xda member suggested me to flatten it before saving.This compiles successfully but creates a white background for all images
 

cowsquad

Senior Member
Aug 31, 2009
1,383
323
Portland, Oregon
OnePlus 9 Pro
ya i was editing .9 pngs.and one of xda member suggested me to flatten it before saving.This compiles successfully but creates a white background for all images

Working with 9.pngs isn't easy to do. You must use 9.png tool to work with those. 9.pngs are pain in the ass. There are tutorials out there man

Sent from my Galaxy Nexus using Tapatalk 2
 
  • Like
Reactions: droidxpert

mekanismen

Senior Member
Nov 20, 2011
342
344
Los Angeles
  • Like
Reactions: droidxpert

Top Liked Posts

  • There are no posts matching your filters.
  • 72
    So, here i'm again porting a tutorial based on DSM_'s Tut :p

    What do you need:
    JRE (Java Runtime Environment)
    MOD EDIT: Download Removed.

    Install:

    Windows:
    MOD EDIT: Download Removed.
    MOD EDIT: Download Removed.
    Unpack both pakages you will get three files, copy those files to your Windows directory i.e. C:\WINDOWS

    Decoding files:
    Open Command. Run>cmd
    Type-
    Quote
    apktool d file.apk [directory]
    Example - apktool d D:\nfsshift.apk D:\nfsshift
    Done!
    2cb75a6e1d9197197a14ac63c8d136558abcc3440521a403287e1d3f2764ee906g.jpg


    FrameworkFiles

    Apktool needs the framework files to decode and build apks.

    Standard framework is embedded into apktool, so you don't need to do anything for most apk files. But some manufacturers, for example Samsung, add their own framework files and use them in system apps. To use apktool against such apps, you must pull framework from a device and install/register it to apktool.

    For Example, you want to decode TouchWizLauncher.apk from Android v2.2 of Galaxy 5. If you try to do that, you will get an error message:
    3d0a604c39d930977d46081df02b7cb857c1c1b2cab72b32172f6ba91450d3f56g.jpg


    You need to install framework in apktool Type-

    apktool if [framework location]


    I have the got the framework-res.apk & twframework-res.apk by extracting the ROM. You can also copy it from your phone. But take care you must copy framework.apk from that ROM in which you got the Application file.

    bcc1201522b5a649ac783b00b32e631e3f6ac5bcd628d21629ee339321c7708c6g.jpg



    Then try again
    a053e9fbaa0bded3b7244dc262c6198c3f37a6fc3ab84e253090af9b404641636g.jpg


    Now is working.


    How to build decoded files:
    Just type

    apktool b [directory in which you have decoded the files]
    Example - apktool b D:\nfsshift
    Done!
    244bedf181e890220ea49c4422a3c4e0310c404b68afba7b23872826443006c26g.jpg



    You will find the apk file inside the decoded directory, like I found it in - D:\nfsshift\dist\nfsshift.apk

    Now you need to sign your APK file.


    How to Sign APK files:


    When publishing an application or a custom rom you need to sign the .apk or .zip files with a certificate using a private key. The Android system uses the certificate to identify the author of an application and establish trust relationship between applications. The classic way of doing this was to use keytool then sign it with jarsigner. In this tutorial i’ll explain an alternative method which is relatively easy to use for most people using a tool called SignApk.jar.

    First download the SignAPK toolMOD EDIT: Download Removed.
    Extract them to a directory you will remember. I have put them in C:\SignApk

    Now just open cmd and type -
    Quote

    cd C:\SignApk
    java -jar signapk.jar certificate.pem key.pk8 your-app.apk your-app-signed.apk
    Example - java -jar signapk.jar certificate.pem key.pk8 D:\nfsshift\dist\nfsshift.apk D:\nfsshift\dist\nfsshift-signed.apk

    05d99cd24c230bc0cc51cad2eee53b61240d5267f2a85c1c2005d7d304833f5b6g.jpg


    Your APK is signed and can be installed.
    1
    Why I get errors when trying to decode some apk's from Xperia S? Apk's are okay, working on phone. Decompiling works on other apps.

    I've registered framework-res.apk from my phone.

    You may require another one like the dhd has com.htc.resources.apk

    sent from my dhd
    1
    @goldiecalypso

    SystemUi.apk isn't a simple package.

    If I'm right you don't have to decompile sources.

    apktool d -s SystemUI.apk

    -s, --no-src (Will not decode sources)
    1
    could u plz tell me hw to do it in ubuntu

    What do you want to know?

    Sent from my Galaxy Nexus using Tapatalk 2
    1
    sir i decompiled framework-res.apk and i have modded the pngs in drawable ldpi folder.but when i am trying to recompile it it shows errors in every png i modded..i modded using photoshop cs6...please help

    What kind of error are you getting? Where you messing with 9.pngs?

    Sent from my Galaxy Nexus using Tapatalk 2