Pages

adcode

26 Dec 2017

How to get source code from .apk?


Are you an Android enthusiast? Did you ever wish to customize an app to your needs? Wondered how you can get source code of an android app?
In this post, I will teach you how to get source code of an android apk file along with resource files like xml files, images,icons everything that is part of an apk.
Here is the video showing how to do it
Step 1: Download the apk file for which you want the source code. Use this link to download apk files directly from Playstore. – http://apps.evozi.com/apk-downloader/
  • Paste the package name or Play Store URL
  • Click on Generate Download Link
  • Then Click Download.
Step 2: Download the following resources.
  • Download apktool-install-windows-r05-ibot.tar.bz2 ( for windows ) and apktool1.5.2.tar.bz2 from here – https://code.google.com/p/android-apktool/downloads/list
    • And extract these two folders and you get 3 files. Put all these files in one folder –  aapt.exe, apktool.bat and apktool.jar
    • Copy the apk file into this folder.
  • Open CMD and change directory to the folder where you have aapt.exe and other files. ( Press shift and right click in dex2jar folder to open command prompt there – a shortcut)
    • run this command –  apktool decode apk-file-name.apk
    • You get All Resource files ( media files, xml files )and AndroidManifest.xml  inside the folder com.test.app folder.
Step 3: Keep a copy of apk file and rename the .apk file to test.zip and extract using any unzipping softwares. ( rename test.apk to test.zip and extract.). You will have a folder with the zip-file name ( for example here “test”).

Step 4: Now extract dex2jar file you downloaded
  • move the classes.dex file in test folder (from the apk you just extracted in Step 3 ) into dex2jar folder.
  • Open CMD and change directory to dex2jar folder. ( Press shift and right click in dex2jar folder to open command prompt there – a shortcut)
  • type  d2j-dex2jar classes.dex and you will get a file classes-dex2jar.jarfile in dex2jar folder.
Step 5: Open jd-gui, click on File, Open and select the classes-dex2jar.jar file you got in the previous step and click on File, Save all resources and save it to file.
  • Now extract that file you will get all the .java files for that apk.
  • Create a new folder src in  com.test.app folder you got in Step 2 and move the contents of folder created in Step 5 by jd-gui into src folder.
Now you have got all the resources and java files for the apk file.
Happy Customizing.
Feel free to comment or suggest.

No comments:

Post a Comment