[GUIDE] How to decompile/compile apks with ApkManager 2/26/14

Search This thread

jds3118

Inactive Recognized Contributor
Oct 19, 2011
4,601
4,457
ocala
Samsung Galaxy S8+
OnePlus 6T
@TheSickness knows his stuff! His guides and help has been invaluable! Thanks to him for all his help!
My first attempt at a theme [emoji4]

Spoiler
51beb5821dddea9232986c50bfc0215e.jpg
7b5ba7735f89a81d428dba1b4b085905.jpg
8316a53a98e31bd1d78a38ae82e6b0c6.jpg
fccd2b9b05499798e2ab114e91de448c.jpg
736c19c4b93bfd060337ea0072302a8f.jpg
195fb6cbfc3ae6d2187f83418a9b1abe.jpg
 

Hybrid Divide

Senior Member
Dec 1, 2014
344
80
LG V20
Moto G Power
Ok. Going through this more is really confusing me.

So I found the Smali file I needed to edit, as I explained in my last post. I edited it.

I didn't need to extract anything from the classes.dex, as all the smali files seem to have been extracted when I decompiled the systemui.apk. But when I go into the keep folder to remove the files I edited, all I see is a classes.dex file. How can I remove the one smali file I edited, if it's already inside a bigger dex file?

Can you see where I'm a bit confused between your two tutorials? I know I'm close. I'm just confused.

Thanks again for your help.
 

The Sickness

Retired Recognized Developer
Oct 27, 2012
9,785
22,733
Somewhere in Texas
Thanks. Would I be able to edit them in Notepad ++?

I used notepad's "Find in Files" search to find the value I wanted to edit, it was able to find it in the smali file.

(I've been trying to change "THE SICKNESS" seen in the pulldown bar to something else. When I searched, the only result was found here: SystemUI.apk\smali\com\android\systemui\statusbar\policy\NetworkController.smali)
Not trying to remove credit for your work, of course. Just trying to make it my own. You understand, I'm sure. :D

Or would you say the method listed in your tutorial to be the best for editing this?

Thanks again!

Yes you must use Note Pad++.

And I believe that's the correct smali.

You can mod my rom to your liking. Just as long as it's for you and not posted
 
  • Like
Reactions: jds3118

Hybrid Divide

Senior Member
Dec 1, 2014
344
80
LG V20
Moto G Power
STILL having problems. Since I wasn't actually modding any XML files, I started over with your Smali tutorial, got my values changed, put the new classes.dex file in the apk and put it back on my phone.

But I kept getting errors that systemui.apk had stopped. Even after managing to get into my root explorer and changing the permissions back to 0644 and restarting my phone.

Clearly I'm missing something here. Also, if I were decompiling and recompiling the systemui.apk, how would I incorporate smali edits into that? Your tutorial, doesn't really make that clear.

Help? Thanks.
 

The Sickness

Retired Recognized Developer
Oct 27, 2012
9,785
22,733
Somewhere in Texas
Ok. Going through this more is really confusing me.

So I found the Smali file I needed to edit, as I explained in my last post. I edited it.

I didn't need to extract anything from the classes.dex, as all the smali files seem to have been extracted when I decompiled the systemui.apk. But when I go into the keep folder to remove the files I edited, all I see is a classes.dex file. How can I remove the one smali file I edited, if it's already inside a bigger dex file?

Can you see where I'm a bit confused between your two tutorials? I know I'm close. I'm just confused.

Thanks again for your help.

Smali edits will not be in the "keep" folder. If, and I say IF all you do is edit smali, just recompile.

Smali can be edited with ApkManager and the program in my guide.
Using the program requires that you use 7Zip to get the class.dex, and you the program to edit the smali.....

Easiest way is to just use ApkManager.
 
  • Like
Reactions: jds3118

Hybrid Divide

Senior Member
Dec 1, 2014
344
80
LG V20
Moto G Power
I've noticed that after I recompile the apk, when I open it up in 7zip, there is a resources.arsc file there. Even if I deleted it previously. Is this normal?

Do I keep it? Or delete it?

EDIT: Nevermind! It works now! Yay!
Thank you for all your help!

EDIT 2: It is still working, but I've noticed that with just that one edit, the file size has gone down from 9.8 MB to 7.9 MB. That CAN'T be normal, can it?
 
Last edited:
  • Like
Reactions: The Sickness

Top Liked Posts

  • There are no posts matching your filters.
  • 25



    APK MODDING THE EASY WAY

    Another Deviant Development Production



    I have had several request on how to edit apks. So I figured I would write a guide for everyone to use, and for me to give
    back to the XDA community. Please keep in mind that this is the tool that I use personally, and I will also do my best to
    explain this guide in detail so you will have confidence in your adventure of modding apks.

    In order to edit your apks there are a couple of more tools that we will need to get. Below you will find the download
    links for the tools.

    Set up requirements

    Downloads

    ApkManager
    This is a zip file. Make sure that you extract it to the root of your
    PC (C:drive)......

    NotePad++
    This will be use to edit xmls

    7Zip
    This will be used to extract certain files needed to compile successfully


    Now, after you have downloaded the above tools please follow these steps or you will have
    errors when you decompile/compile a apk.....

    DECOMPILING

    1. Open Apkmanger and look at the folders to get familiar with them. The first folder we will
    deal with will be the "other" folder.
    In the "other" folder you need to place these 3 apks...
    Framework-res.apk
    SystemUI.apk
    Twframework-res.apk

    Once you have placed these apks in the "other" folder you need to highlight (left click) it, then press shift/right click.
    It will bring up a window....select "open command window here". Once that is done another screen will pop up which
    is cmd....
    In cmd type these commands....
    apktool if framework-res.apk (hit enter on your keyboard) framework is now loaded
    apktool if systemui.apk (hit enter on your keyboard) systemui is now loaded
    apktool if twframework-res.apk (hit enter on your keyboard) twframework is loaded

    2. Now open the "other" folder in a new window. Once its open you need to drag and drop the 3 apks (SystemUI,Framework,
    Twframework)into the folder called "place-apk-here-for-modding". Close the "other" folder.

    3. Now you will see "Script".....double click to open it up. Once its open, type 22. It will bring up the 3 apks that we loaded
    thru cmd.....now choose the apk you wish to mod.

    I will use framework-res.apk for a example. After you have chosen your apk the Script will go to its menu. Type 9 to decompile your apk. It will take it a few minutes. Once its done decompiling the files will be located in the "projects" folder.
    Open the "projects" folder and you will find your decompiled apk.
    Now lets say you wanted to edit a xml in framework.....navigate to res/values. Open it up.....there will be a list of the xml's.
    Right click the xml to bring up a window, select "edit with NotePad++. Now you can edit the xml. (This is just examples
    on the res folder).

    RECOMPILING

    4. Recompiling is where people have problems. Either from compiling errors or bootloops. I will show you how to compile
    with no errors and no bootloops. I will start with framework-res.apk (as example)

    Once you have done all of your edits in framework you will nedd to compile it. Open "Script" again, type 22, type 1, it will bring you to the main menu, type 11 for compile....it will take a few minutes.
    At the bottom of the menu you you will be asked if this is a system app....type Y when it asks. It will then ask if you want to copy over additional files to reduce errors....type Y when it asks. It will then extract a bunch of files.
    Once its done you will now see a "keep" folder. This folder is the original UNMODDED apk you have edited. Now in the "keep" folder you need to DELETE anything you modded. ie (you modded the clock,res/layout/statusbar.xml). You will go to res/layout/statusbar.xml and DELETE the xml.
    Now since you edited a xml you will also have to delete resources.arsc file. This is where xml's are stored. Once you have
    deleted your edits press ok in the "Script". Once its done compileing your new apk will be found in "place-apk-here-for-modding". It will say "unsignedframework-res.apk.

    7ZIP


    But we are not done yet. You will now need to open the ORIGINAL framework-res.apk with 7Zip. Once its open, extract the META-INF and the AndroidManifest. Now you need to open the unsignedframework-res.apk with 7Zip. Once open DELETE META-INF and AndroidManifest. Take the META-INF and AndroidManifest from the original apk and place them into the new one. Once thats done close 7Zip. Rename the apk to framework-res.apk. Your done.


    Please note that you can mod any apk with this tool. You just load them in as above.




    Smali/Dex Files

    Part 2

    Set Up Requirements:

    Downloads

    Smali

    This tool will be used to extact classout files for editing

    First thing is to download the above Smali. Its a rar file, so there is no need to extract to your C: drive.
    Open it up and get familiar with some of the folders.
    One of the easiest ways to get your dex file is with 7Zip. Which you should of downloaded from Part 1. Please
    keep in mind this is dex files from a apk, not a jar. The smali tool works different for jars.

    Extracting Dex Files

    I will use SystemUI.apk as a example. Take your SystemUI.apk and open it with 7Zip. You will see your classes.dex file.
    Drag and drop the classes.dex to the smali folder, just drop it on the bottom right under
    testkey.x509.pem.

    Now you need to double click on "Quick-Baksmali". A CMD window will pop up. When it is done you
    will see a new folder called "classout". This folder contains the smali files. Navigate to the desired smali
    you want to edit. Just use NotePad++ for your edits.

    Compiling Classout back to classout.dex

    Once you have completed your edits you will now need to "compile" the modded classout file back into
    classout.dex. Double click on "Quick-Smali".....a CMD window will pop up. When its done running the
    script you will see "new-classes.dex".....that is your new modded dex files.

    Now open up your SysytemUI.apk with 7Zip......RENAME new-classes.dex to classes.dex....Now DELETE
    the classes.dex in 7Zip. Drag and drop your new classes.dex into 7Zip. And now your SystemUI.apk
    has freshly modded smali......


    If you have any problems or questions please post them and I will help you out. But I will not do
    the modding for you. Thats what this guide is for.

    3
    MINE.............:p
    3
    OP updated with how to edit Smali....:D
    2
    APKManager link not working.........

    Ok. I will fix it when I get off work. My apologies

    Edit: I just tried it and it works. Having Mega on your PC or app on your phone helps

    My S4 Has Gone Insane
    Deviant Development Team Member
    2
    Thanks for this guide! I think I have a grasp on things. Before I get started I have a question. Rather than pull the files from the Rom on my phone. Would it be ok if I pulled the 3 files I must have and the 1 that I am modding from your Insane KitKat Rom V9, that I have on my desk top on my laptop? Then when done with everthing flash the whole rom again and hope for the best.
    Thanks for your help its greatly appreciated!!:cowboy:

    Sure....I guess I should post a zip so yall call flash the apks.

    Haters Make Me Famous
    Deviant Team Member