Register

How to decompile/compile using apktools

This is a discussion on How to decompile/compile using apktools within the Galaxy Nexus Hacking & Mods [LTE/CDMA] forums, part of the Galaxy Nexus Development category; This guide is for Windows only and I tested it in Windows 7 (64 bit) but should work with any windows version. There might be ...

Page 1 of 5 123 ... LastLast
Results 1 to 10 of 50
Like Tree11Likes

Thread: How to decompile/compile using apktools

  1. #1
    Cassiopeia
    Member #
    2856
    Liked
    4 times
    Join Date
    Jan 2012
    Posts
    78

    How to decompile/compile using apktools

    This guide is for Windows only and I tested it in Windows 7 (64 bit) but should work with any windows version.


    There might be an easier way of doing all of this, but this is what I found works for me. I know there are several other tools out there that automate it for you, but I have not really used them too much except for when I needed to do troubleshooting, since it saves the log when it compiles.

    I like doing it manually so I can understand what is going on exactly. Also I think the automation tools do not come with the right apktool.jar versions to decompile framework-res.

    Download the these apktools that I gathered and put together apktools-ics - Minus , there are several files in there. Apktool 1.4.2, Apktool 1.4.3, apktool.bat, and aapt.exe

    You do not need the sdk installed, but you will need to have Java runtime installed. I am using Java version "1.6.0_29", but I am sure you can just downloaded the latest java runtime.


    First thing you want to do is make sure you keep backups of any apk files just in case.


    What I do is create a folder to work in and call it for example:

    Code:
    c:\apktools
    1) Take the zip and unzip all 4 files to c:\apktools. You can call this folder whatever you want or put it anywhere, that is up to you.

    2) You will need to pull the framework-res.apk from the rom you are working on. Copy it to c:\apktools.

    3) Rename apktool.jar.1.4.2 to apktool.jar

    4) Open a command window and make sure everything you do from now on is while you are in this folder c:\apktools


    We now need to install the framework and type the following:


    Code:
    java -jar apktool.jar if framework-res.apk


    You only need to do this once, unless you are working on a different Rom, then you will need to copy the framework-res.apk from that Rom and run the above command again.

    5) We can now decompile framework-res with apktool (most important thing is to make sure we are using version 1.4.2 or will get errors)'

    at the command prompt type:


    Code:
    java -jar apktool.jar d framework-res.apk
    the d option stands for decompile and you will now see a folder under c:\apktools\framework-res. Here is all the output and can make any changes you want, and then can recompile. I would test to make sure you can recompile before making a lot of changes though.


    6) We will now compile framework-res.apk and what is most important is we need to compile it with apktool version 1.4.3

    So what I do at this point is rename apktool.jar to apktool.1.4.2, and then rename apktool.jar.1.4.3 to apktool.jar

    now we compile by running the following make sure you are still in c:\apktools

    Code:
    java -jar apktool.jar b framework-res
    It will take a few minutes and it should complete without any errors.


    7) Once it is done compiling you will need to go to c:\apktools\framework-res\dist and you will now see your new framework-res.apk


    If you get any errors about plurals when compiling it means you used the wrong version of apktool.jar


    For any other apk including systemUI.apk, you can decompile and recompile with apktool.jar version 1.4.3. Basically you will have to keep renaming the apktool.jar if you doing a lot of building with framework-res, otherwise most of the time you can decompile/recompile all other apk files with 1.4.3


    Just remember to copy any apk you want to decompile right into the root of c:\apktools, run the decompile command and it will create a folder of the output that has the same of the apk file.



    Once you have your apk file built you will need to open it with 7zip, and copy out any files you changed to the original apk. If you only changed xml files, then you just need to copy the resources.arsc file and place it in the original apk file. The reason you need to do this is the siganture will change and you want to keep that intact.
    Last edited by Ghosthunter; 02-04-2012 at 03:04 PM.
    cynkrzy, LadyAngler and hossengor like this.

  2. # ADS
    Ads


  3. #2
    Aquarius
    Member #
    614
    Liked
    507 times
    Join Date
    Dec 2011
    Location
    San Luis Obispo
    Posts
    2,736
    Thanks, appreciate the help

  4. #3
    Cassiopeia
    Member #
    2856
    Liked
    4 times
    Join Date
    Jan 2012
    Posts
    78
    Sure thing let me know if it works for you

  5. #4
    Aquarius
    Member #
    614
    Liked
    507 times
    Join Date
    Dec 2011
    Location
    San Luis Obispo
    Posts
    2,736
    Quote Originally Posted by Ghosthunter View Post
    Sure thing let me know if it works for you
    Absolutely, interesting you have to use an older version to decompile the framework, I finally got the APK-Multi tool to compile it last night, don't ask me how, because it threw a bunch of error's and I absently just typed 00 to quit and the next thing I know it's compiling, but the size of the "unsigned...." file was much smaller than the source Framework file & I figured it wasn't going to work ...

    Just finished reading your instructions, really clear and well done, thanks.

    Bummed I'll have to wait till the weekend to test this out, but commitments gotta be met!

  6. #5
    Rescue Squad
    Member #
    321
    Liked
    242 times
    Twitter
    d1l777
    Join Date
    Nov 2011
    Location
    East Coast, VA
    Posts
    1,189
    Thanks for the files, I've been having a lot of trouble recompiling anything with what I've got now so I'm going to download these and see if I can get it to work. Thanks again!

    ...sent from your local Nexus

    PM with any Questions
    GTalk available upon Request

  7. #6
    Super Moderator
    Member #
    26
    Liked
    1124 times
    Join Date
    Aug 2011
    Location
    psl fla
    Posts
    5,909
    Good info I always wanted to dive into this..thanx..
    cynkrzy likes this.

  8. #7
    Aquarius
    Member #
    614
    Liked
    507 times
    Join Date
    Dec 2011
    Location
    San Luis Obispo
    Posts
    2,736
    Careful Ray, it's rather addicting

  9. #8
    Aquarius
    Member #
    614
    Liked
    507 times
    Join Date
    Dec 2011
    Location
    San Luis Obispo
    Posts
    2,736
    quick note on the installing the framework command (as far as I've gotten so far)

    I had to add the extension ".jar" to apktool in the command like to get it to work

    "java -jar apktool.jar if framework-res.apk"

    don't know if the issue was configuration on my Win7(64bit) laptop or syntax for the command, just thought I'd mention it

    on to Step #2!

  10. #9
    Aquarius
    Member #
    614
    Liked
    507 times
    Join Date
    Dec 2011
    Location
    San Luis Obispo
    Posts
    2,736
    So the missing .jar extension is just a typo, I see the next command includes it. The rest of the instructions worked like a champ, I added the framework, de-compiled and re-compiled systemUI without any problems, now to actually edit some .xml and see if I can change the color on the notification dropdown.

    Thanks so much for this, really made things so much easier!

  11. #10
    Aquarius
    Member #
    614
    Liked
    507 times
    Join Date
    Dec 2011
    Location
    San Luis Obispo
    Posts
    2,736
    This is SOOOOO FREEKIN COOL, I have changed the clock color in the status bar. I'm so jazzed, feel like a kid on Christmas morning.

    Now on to the rest....
    alphawave7 likes this.


 

 
Page 1 of 5 123 ... LastLast

Remove Ads

Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

apktool
,
apktool compile
,
apktool exception in thread main
,

apktool.yml

,

apktools

,
apktools.apk
,
arsc decompila
,
building adb framework-res pathnotexist apktool.yml
,
compile and recompile apk apktool
,
decompile apktool cmd
,
exception in thread main brut.androlib.androlibexception: brut.directory.pathnotexist: apktool.yml
,
how to decompile framework.jar
,
how to use apktool
,
pathnotexist apktool.yml
,
resources.arsc decompile
Click on a term to search for related topics.