[How to] noobs guide to decompile/recompile android application

Search This thread

aguha1044

Senior Member
Apr 29, 2012
105
307
Kolkata
xperiahtcrootingrom.com
Guide to decompile android application

REQUIREMENT

Apktool [click here to download][Thanks to brut.all for this apktool]

Java JDK/JRE 32 bit [please google it guy's]

Little knowledge on cmd ;)
_________________________________________________________________________________________________________________________

Preparation before WORKING

Process :-

1)now install the java in your pc/lappy
then copy the apktool.zip & goto directory C:/
make a folder name apktool (u can name it by watever u like)
now goto that folder & paste the zip
extract that zip there...


2) now copy the .apk or jar file which u wnt to decompile
& paste it on apktool folder.....
also copy the framework-res.apk of that rom &
paste it on that folder..

Decompiling application


3) now open cmd

Your cmd will probly look like this..

C:\users\yourname>

so type in

cd.. (yes include the '..' and press enter after you type each command)

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

cd apktool (and you are in the apktool directory)


4)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

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

5)now to decompile the apk you want to edit.. type this:

apktool d music.apk mod

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

do whatever you want to do with your apk... :D:D:D

NOW RECOMPILING

6)now to recompile your new apk type this:

apktool b mod music-new.apk


mod is the folder with your edited files

music-new.apk is your new apk file

Now we are NOT done... we cannot use the new apk's...


now make two separate folder a & b
copy-paste the original music.apk in 'a'
& music-new.apk in 'b'
use something like 7zip, take the 'resources.arcs' file and any other xml files you edited out of the "new-edited" apk and copy them into Original apk
now add to archive ...the origanl apk in zip format
& at the end of the file name .apk ( i mean give the file format name as .apk insted of .zip)


Now you are almost done.....:thumbup:

IF it is a system app then don't sign it....otherwise u have to sign that app....


[=>Guide On How To Sign The Moded App<=]

NOTE:- If you are getting this error =>" java is not a recognized internal or external command "

[=>Then Follow this Guide<=][Thanks to KartzXDA]:good:


That's all

don't forget to hit thanks or comment....:D:good:



All Mod-Rom by Abhijit Guha(mee)

1} X-zooM[V2] (Netlock free : Transparent Rom):good:


.
.
.
 
Last edited:

lokeshsaini94

Senior Member
May 1, 2012
1,777
3,972
Behind you!!!
Insted of so much to cd folder just right click the folder while holding shift button and you will see adbance options... now open command prompt.. It will save time and is very easy ....

Sent from my GT-S7500 using xda premium
 

virgo2000

Senior Member
Mar 20, 2011
70
13
solved problem lol ... good tutorial ...
xda facebook page should share more tutorials like this!!
 

Attachments

  • trf.jpg
    trf.jpg
    99.6 KB · Views: 2,398
Last edited:
  • Like
Reactions: aguha1044

AlwaysDroid

Senior Member
Mar 17, 2012
967
251
Edmonton
Yeah mine says java is not a recognized internal or external command, operable program or batch file. I probably have to add the environment variable, but im not sure how to.

EDIT: got it.
 
Last edited:

aguha1044

Senior Member
Apr 29, 2012
105
307
Kolkata
xperiahtcrootingrom.com
Yeah mine says java is not a recognized internal or external command, operable program or batch file. I probably have to add the environment variable, but im not sure how to.

EDIT: got it.


You getting this error coz you giving those command in some other directory.........

Note:- First u have to go th that directory or folder where ur apktool files are kept...... then u will not get such error......

Follow that guide from begging then u will get wat I wanna say. best of luck :good:
 

AlwaysDroid

Senior Member
Mar 17, 2012
967
251
Edmonton
You getting this error coz you giving those command in some other directory.........

Note:- First u have to go th that directory or folder where ur apktool files are kept...... then u will not get such error......

Follow that guide from begging then u will get wat I wanna say. best of luck :good:

No, I just forgot to add the java bin to PATH variable. All good :)

Sent from my GT-I9000 using xda premium
 

cowsquad

Senior Member
Aug 31, 2009
1,345
320
Portland, Oregon
For the OP. Some ROMs like miui ROM use two frameworks ( framework-res.apk and framework-miui-res.apk) so you need to specify that on the guide. I am just trying to help :)

tapatalked² cowsquadGnex®
 

KartzXDA

Senior Member
Aug 27, 2012
148
161
Hyderabad
How to setup the environment variable

can you tell how to add JAVA bin? I am getting the same error on cmd. thank you

TECHNICAL INFORMATION

The PATH is the system variable that your operating system uses to locate needed executables from the command line or Terminal window.
The PATH system variable can be set using System Utility in control panel on Windows, or in your shell's startup file on Linux and Solaris.

SOLUTION

Here PATH represents the bin path of installed version of Java that contains classes. (e.g. C:/jdk1.6.0/bin)

Setting Path on Windows
Windows 7

1. Select Computer from the Start menu
2. Choose System Properties from the context menu
3. Click Advanced system settings > Advanced tab
4. Click on Environment Variables, under System Variables, find PATH, and click on it.
5. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH,
you may select to add a new variable and add PATH as the name and the location of the class as the value.
6. Reopen Command prompt window, and run your java code.

Windows XP

1. Start -> Control Panel -> System -> Advanced
2. Click on Environment Variables, under System Variables, find PATH, and click on it.
3. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH,
you may select to add a new variable and add PATH as the name and the location of the class as the value.
4. Close the window.
5. Reopen Command prompt window, and run your java code.

Windows Vista

1. Right click My Computer icon
2. Choose Properties from the context menu
3. Click Advanced tab (Advanced system settings link in Vista)
4. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may
select to add a new variable and add PATH as the name and the location of the class as the value.
5. Reopen Command prompt window, and run your java code.


Setting Path on Solaris and Linux

To find out if the java executable is in your PATH, execute:
% java -version

This will print the version of the java executable, if it can find it. If you get error java: Command not found. Then path is not properly set.

To find out which java executable the first one found in your PATH, execute:
% which java

Below are the steps to set the PATH permanently,
Giving instructions for two most popular Shells on Linux and Solaris.



For bash Shell:


Edit the startup file (~/ .bashrc)
Modify PATH variable:
PATH="$PATH":/usr/local/jdk1.6.0/bin
export PATH
Save and close the file
Open new Terminal window
Verify the PATH is set properly
% java -version


For C Shell (csh):

Edit startup file (~/ .cshrc)
Set Path
set path="$PATH":/usr/local/jdk1.6.0/bin
Save and Close the file
Open new Terminal window
Verify the PATH is set properly
% java -version



Hit "Thanks" if anyone helped you. :good:

Xperia Arc LT15i
Rooted/Bootloader Unlocked
JellyBean - FXP137/CM10
 

zain0300

Senior Member
May 7, 2012
1,050
618
San Diego
TECHNICAL INFORMATION

The PATH is the system variable that your operating system uses to locate needed executables from the command line or Terminal window.
The PATH system variable can be set using System Utility in control panel on Windows, or in your shell's startup file on Linux and Solaris.

SOLUTION

Here PATH represents the bin path of installed version of Java that contains classes. (e.g. C:/jdk1.6.0/bin)

Setting Path on Windows
Windows 7

1. Select Computer from the Start menu
2. Choose System Properties from the context menu
3. Click Advanced system settings > Advanced tab
4. Click on Environment Variables, under System Variables, find PATH, and click on it.
5. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH,
you may select to add a new variable and add PATH as the name and the location of the class as the value.
6. Reopen Command prompt window, and run your java code.

Windows XP

1. Start -> Control Panel -> System -> Advanced
2. Click on Environment Variables, under System Variables, find PATH, and click on it.
3. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH,
you may select to add a new variable and add PATH as the name and the location of the class as the value.
4. Close the window.
5. Reopen Command prompt window, and run your java code.

Windows Vista

1. Right click My Computer icon
2. Choose Properties from the context menu
3. Click Advanced tab (Advanced system settings link in Vista)
4. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may
select to add a new variable and add PATH as the name and the location of the class as the value.
5. Reopen Command prompt window, and run your java code.


Setting Path on Solaris and Linux

To find out if the java executable is in your PATH, execute:
% java -version

This will print the version of the java executable, if it can find it. If you get error java: Command not found. Then path is not properly set.

To find out which java executable the first one found in your PATH, execute:
% which java

Below are the steps to set the PATH permanently,
Giving instructions for two most popular Shells on Linux and Solaris.



For bash Shell:


Edit the startup file (~/ .bashrc)
Modify PATH variable:
PATH="$PATH":/usr/local/jdk1.6.0/bin
export PATH
Save and close the file
Open new Terminal window
Verify the PATH is set properly
% java -version


For C Shell (csh):

Edit startup file (~/ .cshrc)
Set Path
set path="$PATH":/usr/local/jdk1.6.0/bin
Save and Close the file
Open new Terminal window
Verify the PATH is set properly
% java -version



Hit "Thanks" if anyone helped you. :good:

Xperia Arc LT15i
Rooted/Bootloader Unlocked
JellyBean - FXP137/CM10

i read all this but still could not figured it out since there were few options i did not find on my windows 7 laptop.

Edit: Ok i found all the options now but what does this mean "modify PATH by adding the location of the class to the value for PATH"?
 
Last edited:

KartzXDA

Senior Member
Aug 27, 2012
148
161
Hyderabad
i read all this but still could not figured it out since there were few options i did not find on my windows 7 laptop.

Edit: Ok i found all the options now but what does this mean "modify PATH by adding the location of the class to the value for PATH"?

Under system variables, find for the variable Path. Click on Edit. Then one window will come up with two text boxes. One is variable name and another one is variable value. Edit the variable value of text box. Add the the path of bin ( e.g., ; C:\jdk\bin [Don't forget to add semicolon before the path]) to the text box.

Please have a look at the attachments.

Hit "Thanks" if anyone helped you.

Xperia Arc LT15i
Rooted/Bootloader Unlocked
JellyBean - FXP137/CM10
 

Attachments

  • 1.JPG
    1.JPG
    32.5 KB · Views: 291
  • 2.JPG
    2.JPG
    10.5 KB · Views: 272
Last edited:

zain0300

Senior Member
May 7, 2012
1,050
618
San Diego
Under system variables, find for the variable Path. Click on Edit. Then one window will come up with two text boxes. One is variable name and another one is variable value. Edit the variable value of text box. Add the the path of bin ( e.g., ; C:\jdk\bin [Don't forget to add semicolon before the path]) to the text box.

Please have a look at the attachments.

Hit "Thanks" if anyone helped you.

Xperia Arc LT15i
Rooted/Bootloader Unlocked
JellyBean - FXP137/CM10

thankx for your replies. I mistakenly deleted all the other paths that were already there, can I bring them back?
thanks button pushed.
 

KartzXDA

Senior Member
Aug 27, 2012
148
161
Hyderabad
thankx for your replies. I mistakenly deleted all the other paths that were already there, can I bring them back?
thanks button pushed.

copy this in the path variable value after that add ;C:\jdk....\bin

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShel l\v1.0\

Hit "Thanks" if anyone helped you. :good:

Xperia Arc LT15i
Rooted/Bootloader Unlocked
JellyBean - FXP137/CM10
 

Top Liked Posts

  • There are no posts matching your filters.
  • 129
    Guide to decompile android application

    REQUIREMENT

    Apktool [click here to download][Thanks to brut.all for this apktool]

    Java JDK/JRE 32 bit [please google it guy's]

    Little knowledge on cmd ;)
    _________________________________________________________________________________________________________________________

    Preparation before WORKING

    Process :-

    1)now install the java in your pc/lappy
    then copy the apktool.zip & goto directory C:/
    make a folder name apktool (u can name it by watever u like)
    now goto that folder & paste the zip
    extract that zip there...


    2) now copy the .apk or jar file which u wnt to decompile
    & paste it on apktool folder.....
    also copy the framework-res.apk of that rom &
    paste it on that folder..

    Decompiling application


    3) now open cmd

    Your cmd will probly look like this..

    C:\users\yourname>

    so type in

    cd.. (yes include the '..' and press enter after you type each command)

    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

    cd apktool (and you are in the apktool directory)


    4)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

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

    5)now to decompile the apk you want to edit.. type this:

    apktool d music.apk mod

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

    do whatever you want to do with your apk... :D:D:D

    NOW RECOMPILING

    6)now to recompile your new apk type this:

    apktool b mod music-new.apk


    mod is the folder with your edited files

    music-new.apk is your new apk file

    Now we are NOT done... we cannot use the new apk's...


    now make two separate folder a & b
    copy-paste the original music.apk in 'a'
    & music-new.apk in 'b'
    use something like 7zip, take the 'resources.arcs' file and any other xml files you edited out of the "new-edited" apk and copy them into Original apk
    now add to archive ...the origanl apk in zip format
    & at the end of the file name .apk ( i mean give the file format name as .apk insted of .zip)


    Now you are almost done.....:thumbup:

    IF it is a system app then don't sign it....otherwise u have to sign that app....


    [=>Guide On How To Sign The Moded App<=]

    NOTE:- If you are getting this error =>" java is not a recognized internal or external command "

    [=>Then Follow this Guide<=][Thanks to KartzXDA]:good:


    That's all

    don't forget to hit thanks or comment....:D:good:



    All Mod-Rom by Abhijit Guha(mee)

    1} X-zooM[V2] (Netlock free : Transparent Rom):good:


    .
    .
    .
    5
    How to setup the environment variable

    can you tell how to add JAVA bin? I am getting the same error on cmd. thank you

    TECHNICAL INFORMATION

    The PATH is the system variable that your operating system uses to locate needed executables from the command line or Terminal window.
    The PATH system variable can be set using System Utility in control panel on Windows, or in your shell's startup file on Linux and Solaris.

    SOLUTION

    Here PATH represents the bin path of installed version of Java that contains classes. (e.g. C:/jdk1.6.0/bin)

    Setting Path on Windows
    Windows 7

    1. Select Computer from the Start menu
    2. Choose System Properties from the context menu
    3. Click Advanced system settings > Advanced tab
    4. Click on Environment Variables, under System Variables, find PATH, and click on it.
    5. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH,
    you may select to add a new variable and add PATH as the name and the location of the class as the value.
    6. Reopen Command prompt window, and run your java code.

    Windows XP

    1. Start -> Control Panel -> System -> Advanced
    2. Click on Environment Variables, under System Variables, find PATH, and click on it.
    3. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH,
    you may select to add a new variable and add PATH as the name and the location of the class as the value.
    4. Close the window.
    5. Reopen Command prompt window, and run your java code.

    Windows Vista

    1. Right click My Computer icon
    2. Choose Properties from the context menu
    3. Click Advanced tab (Advanced system settings link in Vista)
    4. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may
    select to add a new variable and add PATH as the name and the location of the class as the value.
    5. Reopen Command prompt window, and run your java code.


    Setting Path on Solaris and Linux

    To find out if the java executable is in your PATH, execute:
    % java -version

    This will print the version of the java executable, if it can find it. If you get error java: Command not found. Then path is not properly set.

    To find out which java executable the first one found in your PATH, execute:
    % which java

    Below are the steps to set the PATH permanently,
    Giving instructions for two most popular Shells on Linux and Solaris.



    For bash Shell:


    Edit the startup file (~/ .bashrc)
    Modify PATH variable:
    PATH="$PATH":/usr/local/jdk1.6.0/bin
    export PATH
    Save and close the file
    Open new Terminal window
    Verify the PATH is set properly
    % java -version


    For C Shell (csh):

    Edit startup file (~/ .cshrc)
    Set Path
    set path="$PATH":/usr/local/jdk1.6.0/bin
    Save and Close the file
    Open new Terminal window
    Verify the PATH is set properly
    % java -version



    Hit "Thanks" if anyone helped you. :good:

    Xperia Arc LT15i
    Rooted/Bootloader Unlocked
    JellyBean - FXP137/CM10
    3
    i read all this but still could not figured it out since there were few options i did not find on my windows 7 laptop.

    Edit: Ok i found all the options now but what does this mean "modify PATH by adding the location of the class to the value for PATH"?

    Under system variables, find for the variable Path. Click on Edit. Then one window will come up with two text boxes. One is variable name and another one is variable value. Edit the variable value of text box. Add the the path of bin ( e.g., ; C:\jdk\bin [Don't forget to add semicolon before the path]) to the text box.

    Please have a look at the attachments.

    Hit "Thanks" if anyone helped you.

    Xperia Arc LT15i
    Rooted/Bootloader Unlocked
    JellyBean - FXP137/CM10
    3
    I decompiled everything fine alright... Made a few changes and got errors. I even tried to recompile without any changes and still I get this error.

    error.png


    This is a SystemUI.apk of ICS Stock Xperia U ROM

    Make sure you are using latest apktool and aapt
    It looks to be aapt issue
    Get it from here and from now post your issues in below thread as iBotPeaches is developer of Apktool.
    http://forum.xda-developers.com/showthread.php?t=1755243

    Hope that helps
    Just wonder, op opened the thread and disappeared for giving assistance to users :silly:
    2
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone