Android: Getting Source Code from an APK file

Just follow the steps mentioned below to decode a mystic .apk file into plain java code.

1.Create a new folder. Name it “SourceCode”(or as you wish). Put your apk file there.

2.Download the file “ApkToJava.rar” from the right hand side of my blog. Extract everything in your SourceCode folder.

3.Edit the extension of your apk file and change it to “zip”. Extract this folder.You can see a file named “classes.dex”.

4.Now from command prompt browse to the folder “dex2jar-0.0.9.8” in the source code folder. Type the following command:

dex2jar ..\classes.dex

You can see a file named “classes_dex2jar.jar” is created  in your SourceCode folder

5.Now from  “Java_decompiler” folder open jd-gui.exe application. Using this application open the file “classes_dex2jar.jar”. You can see all the java codes of the .class files.

6.At this point you can’t view the xml files. To view those follow the step 7 to end.

7.Paste a fresh copy of you .apk file in the SourceCode folder.

From cmd browse to the source code folder. Type the command

: >apktool if framework-res.apk

Hit Enter . Again type:

:>apktool d “name_of_Your_fike”.apk

8.A new folder will be generated with your apk file name.In that directory you’ll be able to browse the .xml file.

 

Good luck with your code hunt!

Advertisements

9 Comments

    1. Hi prashant, this command is executing ‘classes.dex’ file from parent directory.In windows this sign ‘..\’ denotes parent directory.If you put your classes.dex file in the folder ‘dex2jar-0.0.9.8’ ,you may try the command:
      ‘ dex2jar classes.dex’.

      1. no still it’s not working please send me a whole steps one by one i simple and full manner…please
        thanks

  1. hi I got the error on command prompt

    error occured during initialization of vm.
    could nt reserve enough space for object heap
    could not create java virtual machine
    so how can I solve it .Help me.reply as soon as possible

  2. I have successfully fetch the class file from apk but can not able to fetch data from step no 7. I did exactly according to instruction….. what should I do….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s