[Guide] Decompile with Apk Tool [Easy Way]

Search This thread

FenrirMX

Senior Member
Apr 5, 2012
337
134
Troy, MI
Overall, it seems simple enough, here's the deal though.
I install the framework. No problem
I decompile the apk (a live wallpaper). No problem
I modify an XML (just one of the color values). No problem.
I recompile. No problem.
I move the resources.arsc into the original apk. No problem.
I try to install it to my phone. NO GO. Says Install failed.

So, what went wrong? :confused:
 

Difusal

Senior Member
Jul 3, 2011
461
415
London, UK
I'm trying to compile an application but I'm having no luck. I can't even compile an untouched app, i.e., if I decompile mms.apk (no errors at all) and I tried to compile right on, it doesn't work! I have done this before when I still used windows 7 so idk why it isn't working.

One thing I noticed is that the frameworks get installed to C:\Windows\system32\config\systemprofile\apktool\framework\1.apk is that okay? I'm using windows 8 now if that makes any difference.

anyway, here is the output I get:
v83fkj.png


thanks!
 

K.A.

Senior Member
Apr 4, 2012
6,360
1,272
I'm trying to compile an application but I'm having no luck. I can't even compile an untouched app, i.e., if I decompile mms.apk (no errors at all) and I tried to compile right on, it doesn't work! I have done this before when I still used windows 7 so idk why it isn't working.

One thing I noticed is that the frameworks get installed to C:\Windows\system32\config\systemprofile\apktool\framework\1.apk is that okay? I'm using windows 8 now if that makes any difference.

anyway, here is the output I get:
v83fkj.png


thanks!
Check if that folder exists. If it does, delete the 1.apk and other files in there. Take the framework-res of the rom whose mms.apk you've taken, and do "apktool if framework-res.apk". Then decompile and recompile and see. Also, if it's stock, you'll need twframework-res.apk.
Also, shouldn't it be apktool b mms.apk? :confused:
 

Difusal

Senior Member
Jul 3, 2011
461
415
London, UK
Check if that folder exists. If it does, delete the 1.apk and other files in there. Take the framework-res of the rom whose mms.apk you've taken, and do "apktool if framework-res.apk". Then decompile and recompile and see. Also, if it's stock, you'll need twframework-res.apk.
Also, shouldn't it be apktool b mms.apk? :confused:

didn't work, it just gives me the same error.. :/

if I type apktool b mms.apk (instead of apktool b mms) I get:

C:\Android\apktool>apktool b mms.apk
Exception in thread "main" brut.androlib.AndrolibException: brut.directory.PathN
otExist: apktool.yml
at brut.androlib.Androlib.readMetaFile(Androlib.java:164)
at brut.androlib.Androlib.build(Androlib.java:183)
at brut.androlib.Androlib.build(Androlib.java:176)
at brut.apktool.Main.cmdBuild(Main.java:228)
at brut.apktool.Main.main(Main.java:79)
Caused by: brut.directory.PathNotExist: apktool.yml
at brut.directory.AbstractDirectory.getFileInput(AbstractDirectory.java:
103)
at brut.androlib.Androlib.readMetaFile(Androlib.java:160)
... 4 more
 

K.A.

Senior Member
Apr 4, 2012
6,360
1,272
didn't work, it just gives me the same error.. :/

if I type apktool b mms.apk (instead of apktool b mms) I get:

C:\Android\apktool>apktool b mms.apk
Exception in thread "main" brut.androlib.AndrolibException: brut.directory.PathN
otExist: apktool.yml
at brut.androlib.Androlib.readMetaFile(Androlib.java:164)
at brut.androlib.Androlib.build(Androlib.java:183)
at brut.androlib.Androlib.build(Androlib.java:176)
at brut.apktool.Main.cmdBuild(Main.java:228)
at brut.apktool.Main.main(Main.java:79)
Caused by: brut.directory.PathNotExist: apktool.yml
at brut.directory.AbstractDirectory.getFileInput(AbstractDirectory.java:
103)
at brut.androlib.Androlib.readMetaFile(Androlib.java:160)
... 4 more
Yep. your mms.apk did not decompile properly. Install frameworks and decompile again. The error shows that the folder containing decompiled apk is missing apktool.yml file, which means decompile wasn't done properly.
 

SpaceCaker

Senior Member
Mar 26, 2011
13,545
10,904
netherlands
www.youtube.com
didn't work, it just gives me the same error.. :/

if I type apktool b mms.apk (instead of apktool b mms) I get:

C:\Android\apktool>apktool b mms.apk
Exception in thread "main" brut.androlib.AndrolibException: brut.directory.PathN
otExist: apktool.yml
at brut.androlib.Androlib.readMetaFile(Androlib.java:164)
at brut.androlib.Androlib.build(Androlib.java:183)
at brut.androlib.Androlib.build(Androlib.java:176)
at brut.apktool.Main.cmdBuild(Main.java:228)
at brut.apktool.Main.main(Main.java:79)
Caused by: brut.directory.PathNotExist: apktool.yml
at brut.directory.AbstractDirectory.getFileInput(AbstractDirectory.java:
103)
at brut.androlib.Androlib.readMetaFile(Androlib.java:160)
... 4 more

You get that because you cant compile a apk to a apk
 

Difusal

Senior Member
Jul 3, 2011
461
415
London, UK
is something missing in my path?

C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin;C:\Program Files (x86)\QuickTime\QTSystem\;C:\android\android-sdk\platform-tools;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Android\apktool\;C:\Program Files\Java\jdk1.7.0_15\bin\;C:\Android\sdk\tools\
 

Difusal

Senior Member
Jul 3, 2011
461
415
London, UK
you need to do "apktool b mms xxx.apk"
replace xxx with whatever name you want for the new apk.

C:\Android\apktool>apktool b mms new.apk
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
W/asset ( 5676): Asset path C:\Windows\system32\config\systemprofile\apktool\f
ramework\1.apk is neither a directory nor file (type=1).
ERROR: Asset package include 'C:\Windows\system32\config\systemprofile\apktool\f
ramework\1.apk' not found.
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.Androl
ibException: brut.common.BrutException: could not exec command: [aapt, p, --min-
sdk-version, 16, --target-sdk-version, 16, -F, C:\Users\Henrique\AppData\Local\T
emp\APKTOOL7834780375363419715.tmp, -I, C:\Windows\system32\config\systemprofile
\apktool\framework\1.apk, -S, C:\Android\apktool\mms\res, -M, C:\Android\apktool
\mms\AndroidManifest.xml]
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:358)
at brut.androlib.Androlib.buildResources(Androlib.java:283)
at brut.androlib.Androlib.build(Androlib.java:206)
at brut.androlib.Androlib.build(Androlib.java:176)
at brut.apktool.Main.cmdBuild(Main.java:228)
at brut.apktool.Main.main(Main.java:79)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not
exec command: [aapt, p, --min-sdk-version, 16, --target-sdk-version, 16, -F, C:
\Users\Henrique\AppData\Local\Temp\APKTOOL7834780375363419715.tmp, -I, C:\Window
s\system32\config\systemprofile\apktool\framework\1.apk, -S, C:\Android\apktool\
mms\res, -M, C:\Android\apktool\mms\AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
a:357)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:336)
... 5 more
Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-sd
k-version, 16, --target-sdk-version, 16, -F, C:\Users\Henrique\AppData\Local\Tem
p\APKTOOL7834780375363419715.tmp, -I, C:\Windows\system32\config\systemprofile\a
pktool\framework\1.apk, -S, C:\Android\apktool\mms\res, -M, C:\Android\apktool\m
ms\AndroidManifest.xml]
at brut.util.OS.exec(OS.java:89)
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
a:355)
... 6 more
 

Difusal

Senior Member
Jul 3, 2011
461
415
London, UK
I just tried to do the exact same thing on another windows 8 computer and it worked like a charm! What the hell is wrong on my computer??
And the framework installed correctly in C/users. my laptop is installing in system32... -.-
 

K.A.

Senior Member
Apr 4, 2012
6,360
1,272
As i can see on ur pc you dont have the frameworks installed

(1.apk)



Sent from my ST25i using xda app-developers app
Exactly.
You need to do

apktool if framework-res.apk

in the folder containing the framework-res of the ROM whose mms you're trying to mod. If it is stock you will need to do

apktool if twframework-res.apk
 

cpaixao

Senior Member
Dec 3, 2010
533
121
Sete Lagoas
Hi, great tool and good guide! Congratulations!

Can we find out what is blocking an apk installation by reading its xml manifest?

Thanks!
 

Sami Kabir

Senior Member
Oct 3, 2012
2,233
1,410
Ok I'm a bit confused at the end...

We are NOT done just yet, we cannot use the new apk's... we have to take what we did and add it back to the original apk file to keep proper signature

use something like 7zip, take the 'resources.arcs' file and any other xml files you edited out of the "-new" apk and copy them into Original apk

Your new modded APK is now ready, Congrats!

can you please explain it in detail.. like the instructions, etc..? Thanks :D
 

marvinlh

Senior Member
Oct 28, 2009
2,582
440
New Orleans
im trying to follow the instructions for this thread to get the aosp mms working with wicked sensations tw rom, im also following the instructions from http://xdaforums.com/showthread.php?t=2086834 this is my first time trying to attempt this over even trying to decompile and im kinda stuck. I was at the step where it says install the system framework but its a no go. right now im trying toswich files around in the framework2.jar but cant seem to even get started. any help would be much appriciated
 

Top Liked Posts

  • There are no posts matching your filters.
  • 178


    ## Due to exams I won't be able to reply on questions, there are however many experienced developers active on this thread like @SpaceCaker & @K.A. ##

    I have seen a lot of guides on how to decompile with Apk Tool, but none are noob friendly, so I thought I would post this.

    What You Need:

    ApkTool
    Java JDK/JRE 32 bit
    Super Basic Cmd/terminal knowledge (My 5 year old brother can handle this)



    Download Apk Tool Here: (Must be this one)

    Mega

    First you need to extract that zip folder to anywhere you choose, preferably on root of c/drive E.g: C:/android/apktool extracting the files to 'apktool' folder.

    Now copy the apk you would like to mod into your Apk Tool folder.

    f6f8ecf510f10ce4c2c308a5f8a0ea7b.jpg



    Command Prompt:

    Open up your Command Prompt by going to:
    Start -> run -> type : Cmd

    32013a151ec069c5099725789edc10ac.jpg


    Code:
    Your cmd will probly look like this..
    
    C:\users\yourname>
    
    so type in
    
    cd.. [COLOR="Red"](Yes include the '..' and press enter after you type each command.)[/COLOR]
    
    this will get you to back directory so now you will see
    
    C:\users>
    
    so type again
    
    cd..
    
    you should now see this:
    
    C:\>
    
    now type in:
    
    cd 'apktoo'l/'directory'
    
    for me it looks like:
    
    cd android/apktool
    
    now you should see:
    
    C:/android/apktool>
    
    and you are in the apktool directory

    dd6f52dd0a63e9cfec11257816610e7e.jpg



    Installing Framework:

    Now that you are in directory we need to install the device's framework to your system for it to compile correctly so type this:

    apktool if framework-res.apk

    Remember: Devices like HTC / Samsung / Huawei have other frameworks that are used in their apps too, sometimes you need to install them too.

    This will install the devices framework to your system. (need to do this)

    0469af0a4f59683b5afd65bbaa517560.jpg


    Decompiling:

    Now to decompile the apk you want to edit, type this:

    apktool d framework-res.apk framework1

    or

    apktool d music.apk music

    music.apk is the apk your decompiling
    music is the folder you're creating for the decompiled apk

    Now go about your business :victory:

    66f044a6c2f13780fcc0fc4b7cb664dc.jpg


    3b486e7ae9e032f8eb4bab257abafe7f.jpg



    Recompiling/Finished Product:


    Now to recompile your new apk type this:

    apktool b music music-new.apk

    or

    apktool b framework1 framework-res-new.apk

    framework1 is the folder with your edited files
    framework-res-new.apk is your new apk file

    131ce3032fc2e7ca4371de574ebec108.jpg


    16f0361f73797450f7af2457791b36fd.jpg



    We are NOT done just yet, we cannot use the new apk's... we have to take what we did and add it back to the original apk file to keep proper signature

    use something like 7zip, take the 'resources.arcs' file and any other xml files you edited out of the "-new" apk and copy them into Original apk

    Your new modded APK is now ready, Congrats! :highfive:

    If you get Java errors see here.
    If you recompile fine but doesn't install " App couldn't not be installed " see here.
    Good Luck Guys! :fingers-crossed:

    11
    Fix a corrupted Java Jre ( Development package )

    • Download JavaRa




    • Run with Administrator permissions

    • Click Remove Java Runtime

    ex5FCGf.png


    • Click on Additional Tasks

    CKCvO2t.png


    • Select the following and click Run

    HkBLp3U.png


    ( Remove Startup Entry, Remove Outdated JRE Firefox Extensions, Clean JRE Temp Files. )

    • Re-install from here:



    Note that JavaRA might have updated and has onscreen instructions to help you fix your JRE.

    4
    AFAIK, for systemUI, you need to replace resources.arsc, classes.dex and the res folder..
    Nicely done, btw..
    3
    Has the APK been signed? If not, see Here.
    3
    can u share your apktool stuff ?



    Sent from my ST25i using xda premium
    The aapt file, the apktool jar and apktool file? That only, right?

    ---------- Post added at 11:57 PM ---------- Previous post was at 11:53 PM ----------

    http://www.mediafire.com/?b4au2n8pz1e153p
    This is the 3 files i put..in C:\Windows...