Ever wanted to get your source code back from an .apk file after having lost it? Well here’s how to do it. Losing source code is always a complete annoyance during Android app development, but following this method you can get it back fairly easily. Download links are below and written instructions come after the break:

Prerequisites:

1. Get APK source code files for Windows
or
2. Get APK source code files for Mac OS X
or
3. Get APK source code files for Linux

Step 1. Rename the .apk file you wish to retrieve and change the extension to .zip. Then extract the file that it creates.

Step 2. Copy the contents of the dex2jar folder to the extracted folder to make it easier for yourself, and run:

dex2jar classes.dex

and copy the resulting “classes.dex.dex2jar.jar” into a new folder.

Step 3. Open up the Java Decompiler and drag “classes.dex.dex2jar.jar” into the window and then go to File > Save and save the source in a .zip file.

Step 4. Extract the saved .zip and copy the contents to a new folder somewhere. This will be where we keep your source code.

Step 5. Now, copy “framework-res.apk” and “yourapk.apk” to the APKTool folder. Then open a command prompt or Terminal window and type:

apktool if framework-res.apk apktool d <yourapk.apk>

Step 6. Now just copy the contents of the resulting folder to the same place you copied the contents of “classes.dex.dex2jar.jar” earlier and voila, you have your source code. You may need to remove a couple of things as shown in the video, but your entire code should be there!

15 Responses so far.

  1. john says:

    hello. I did exactly as you explained and got everything OK, but I couldn’t get it into eclipse.

    could you explain me how to do it?

    thanks

    • Sashi Kiran says:

      Thanks for sharing this video. Well explained, perfectly done and an excellent work.
      It worked like a charm…It helped me a lot…thanks again..

      @John: I even able to import to Eclips, its cool nothing complicated.
      1. Navigate to Import section
      2. Select ‘Existing Android project into workshop’ option under ‘Android’ section and click on ‘Next’
      3. In the next screen browse and select the app folder, check the option ‘Copy project into workspace’.

      A app is imported successfully.
      Hope this will help you…

      Cheers..

  2. Darshan says:

    Hi
    Thanks for information,we have successfully tried out all the steps mention To Retrieve Source Code From An Android .APK File. But we are unable to open with Eclips , by trying the below steps.

    1. Navigate to Import section
    2. Select ‘Existing Android project into workshop’ option under ‘Android’ section and click on ‘Next’
    3. In the next screen browse and select the app folder, check the option ‘Copy project into workspace’.

    So we created the new android project in Eclips and copy paste the res src and other files then source code is given lots of error,
    Kindly let use know how to proceed

    • ZackehSoul says:

      I would suggest that if you don’t know how to deal with Eclipse errors, you shouldn’t be messing with code :p

  3. mukul says:

    I am getting some problems during step 3.
    The error is “jd-gui.exe has encountered a problem and needs to close. We are sorry for the inconvenience.” and because of that my .src file is not getting generated. I tried downloading directly from jd-gui website but still the error persists. How can I fix this problem?

  4. Vivian says:

    Is there any way you can get the update version of it please…?

    Thank you.
    I just saw v1.5.2 of the apk tool but there are files missing from the zip that the new version has.

    So could you help us out?

  5. Mehul says:

    It’s working perfectly.Thanks for sharing the knowledge.Cheers!!

  6. manoj says:

    i’m not able tp get the source code u plz help me to retrive an application for me

  7. Kevin says:

    I’m stuck here! Where i can get that framework-res.apk file?

  8. hydro says:

    When he said run in compatablity mode if you have win 7 then choose that if you have vista or whatever systems you have

  9. Mohit says:

    Hi great job! I am done with all the steps and successfully import the project into eclipse workspace..But while running the application I am getting error in my device/emulator as “Unfortunately,Application has stopped”. Can you please help me out with this issue.Help me out on priority basis.Thanks a lot.


  • RSS
  • Facebook
  • Twitter
  • Youtube