Extract source code from APK file.

Hello,

This is a tutorial of how to extract an APK source code

Requirments tools:
1. dex2jar.
2. jd-gui.

I will show you how to extract the source code for a game called “Magic Piano”.
First of all, download the apk file from the internet.
after the download finish, you will have a file called “Magic-Piano-v1.0.1.apk”,
rename it to “Magic-Piano-v1.0.1.zip”, we changed the apk to zip, then extract the zip file.

Open the “Magic-Piano-v1.0.1” folder, you will see many folders and files, we need the files named “classes.dex”
Note: all the game assets, graphics and sound are accessible, you can take and use them.

We need this file, this is the file that contain the source code.

Extract the “dex2jar-0.0.9.8.tar.gz”, that will produce a folder called “dex2jar-0.0.9.8”, copy the “classes.dex” to it.
Now, open the Terminal and navigate to “dex2jar-0.0.9.8” folder. then write this command “sh dex2jar.sh classes.dex”

Now, you will get a file named “classes_dex2jar.jar”. 😛

After that, we will use “java decompiler”, the jd-gui tool, double click on jd-gui and click on open file then open “classes_dex2jar.jar” file from that folder, now you get classes files… save all these classs file (click on file then click “save all sources” in jd-gui), by src name, at this stage you get source.

Video that shows how to do this, hope you enjoy and learn something useful for you,
Please if you like it, share it and if you didn’t get anything, just comment and i will answer you.

T.C.

7 thoughts on “Extract source code from APK file.

  1. There are some exciting points in time in the following paragraphs but I don’t determine I see these center to heart. There’s some quality but I will need hold opinion until My partner and i look into the idea further. Piece of content , thanks and that we want far more! Added to FeedBurner at the same time

    Like

  2. Hi,
    First of all thanks a lot for this great tutorial, such an amazing much needed, so useful keep it up God Bless You
    Using this Tutorial, I am able to get Java, XML files, resources, drawables, manifest etc.
    Actually i am facing some issues in Java code, in short getting many Errors like:
    1. The type of the expression must be an array type but it resolved to Object
    2. Type mismatch: cannot convert from int to LinearLayout
    3. Type mismatch: cannot convert from LinearLayout to int
    4. The method setVisibility(int) in the type View is not applicable for the arguments (LinearLayout)
    5. Type mismatch: cannot convert from int to boolean
    6. – monitorenter cannot be resolved to a variable
    7. – Syntax error, insert “AssignmentOperator Expression” to complete Expression
    8. The label label175 is missing
    9. The local variable localObject may not have been initialized
    Thanks again, i will wait for your reply…

    Like

  3. i am facing some problem in following command
    1.“sh dex2jar.sh classes.dex” is not executing o command promt

    Like

  4. Hi, sheetal.

    If you are using Windows OS you just have to write dex2jar classes.dex.

    The comand sh dex2jar.sh classes.dex is for Unix

    Like

  5. Thanks on your marvelous posting! I actually enjoyed reading it, you can be
    a great author.I will make sure to bookmark your blog and will often come
    back later on. I want to encourage one to continue your great
    writing, have a nice evening!

    Like

  6. Hi, I think your site might be having browser compatibility issues.
    When I look at your blog site in Ie, it looks fine but
    when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up! Other then that, very good blog!

    Like

Leave a comment