How to Extract Code of .Apk File Which Is Not Working

Is there a way to get the source code from an APK file?

Simplest way: use the online tool Decompiler, upload the apk and get the source code.


Procedure for decoding .apk files, step-by-step method:

Step 1:

  1. Make a new folder and copy over the .apk file that you want to decode.

  2. Now rename the extension of this .apk file to .zip (rename from filename.apk to filename.zip) and save it. Now you can access the classes.dex files. At this stage, you are able to see drawables, but not the .xml and .java files.

Step 2:

  1. Now extract this .zip file in the same folder or a new folder.

  2. Download dex2jar (Don't download the code, click on the releases button that's on the right, then download that) and extract it to the same folder or a new folder.

  3. Move the classes.dex file into the dex2jar folder.

  4. Now open Command Prompt and change the directory to that folder. Then write d2j-dex2jar classes.dex (for Mac or Ubuntu write ./d2j-dex2jar.sh classes.dex) and press enter. You now have the classes.dex.dex2jar file in the same folder.

  5. Download java decompiler, Right click on jd-gui, click on Open File, and open classes.dex.dex2jar file from that folder: Now you get the class files.

  6. Save all of these class files (In jd-gui, click File -> Save All Sources) by src name. At this stage, you get the Java code but the .xml files are still unreadable.

Step 3:

Now open another new folder

  1. Put in the .apk file which you want to decode

  2. Download the latest version of apktool AND apktool install window (both can be downloaded from the same link) and place them in the same folder

  3. Open the Command Prompt

  4. Now run command apktool if framework-res.apk (if you don't have it get it here)and next

  5. apktool d myApp.apk (myApp.apk denotes the filename that you want to decode)

Now you get a file folder in that folder and can easily read the .xml files.

Step 4:

It's not any step, just copy the contents of both folders (both new folders) to the single one

AND ENJOY THE SOURCE CODE!

How to extract code of .apk file which is not working?

Any .apk file from market or unsigned

  1. If you apk is downloaded from market and hence signed Install Astro File Manager from market. Open Astro > Tools > Application Manager/Backup and select the application to backup on to the SD card .
    Mount phone as USB drive and access 'backupsapps' folder to find the apk of target app (lets call it app.apk) . Copy it to your local drive same is the case of unsigned .apk.

  2. Download Dex2Jar zip from this link: SourceForge

  3. Unzip the downloaded zip file.

  4. Open command prompt & write the following command on reaching to directory where dex2jar exe is there and also copy the apk in same directory.

    dex2jar targetapp.apk file(./dex2jar app.apk on terminal)

  5. http://jd.benow.ca/ download decompiler from this link.

  6. Open ‘targetapp.apk.dex2jar.jar’ with jd-gui
    File > Save All Sources to sava the class files in jar to java files.

get the source code from an APK file back - the notebook drive crashed

You can try decompiling your APK using ClassyShark. Another good tool is Apktool.

How to extract source code from installed app?

First you go to Android studio's welcome page there is a option to extract source code from APKs.

Another way is to install this apk extractor application from play store then you can extract source code from APKs Link : https://play.google.com/store/apps/details?id=com.ext.ui

Is there a way to get the source code from an APK file?

Simplest way: use the online tool Decompiler, upload the apk and get the source code.


Procedure for decoding .apk files, step-by-step method:

Step 1:

  1. Make a new folder and copy over the .apk file that you want to decode.

  2. Now rename the extension of this .apk file to .zip (rename from filename.apk to filename.zip) and save it. Now you can access the classes.dex files. At this stage, you are able to see drawables, but not the .xml and .java files.

Step 2:

  1. Now extract this .zip file in the same folder or a new folder.

  2. Download dex2jar (Don't download the code, click on the releases button that's on the right, then download that) and extract it to the same folder or a new folder.

  3. Move the classes.dex file into the dex2jar folder.

  4. Now open Command Prompt and change the directory to that folder. Then write d2j-dex2jar classes.dex (for Mac or Ubuntu write ./d2j-dex2jar.sh classes.dex) and press enter. You now have the classes.dex.dex2jar file in the same folder.

  5. Download java decompiler, Right click on jd-gui, click on Open File, and open classes.dex.dex2jar file from that folder: Now you get the class files.

  6. Save all of these class files (In jd-gui, click File -> Save All Sources) by src name. At this stage, you get the Java code but the .xml files are still unreadable.

Step 3:

Now open another new folder

  1. Put in the .apk file which you want to decode

  2. Download the latest version of apktool AND apktool install window (both can be downloaded from the same link) and place them in the same folder

  3. Open the Command Prompt

  4. Now run command apktool if framework-res.apk (if you don't have it get it here)and next

  5. apktool d myApp.apk (myApp.apk denotes the filename that you want to decode)

Now you get a file folder in that folder and can easily read the .xml files.

Step 4:

It's not any step, just copy the contents of both folders (both new folders) to the single one

AND ENJOY THE SOURCE CODE!

How to get source code from apk file in Android?

Have a Look This But Not Geaing All Source Code From Apk File

decompile apk file android

Reverse engineering from an APK file to a project

There are two useful tools which will generate Java code (rough but good enough) from an unknown APK file.

  1. Download dex2jar tool from dex2jar.

  2. Use the tool to convert the APK file to JAR:
    Windows:

     $ d2j-dex2jar.bat demo.apk
    dex2jar demo.apk -> ./demo-dex2jar.jar

    MacOS / Linux:

     $ d2j-dex2jar.sh -f demo.apk -o demo.jar
  3. Once the JAR file is generated, use JD-GUI to open the JAR file. You will see the Java files.

The output will be similar to:

JD GUI

Then you can use other tools to retrieve the AndroidManifest.xml and resource files (like images, translations, etc...) from the APK file.

  • Apktool

     $ java -jar apktool.jar -q decode -f demo.apk -o outputDir
  • AXMLParser

     $ apkinfo demo.apk
  • NinjaDroid

     $ ninjadroid demo.apk --all --extract

Having .apk can extract its source code. Does Android app is secure?

Yes,hopefully There is a way of preventing other from getting your hard labor projects full source code .
Enable ProGuard for your android application. ant will call ProGuard to obfuscate your code.
Your code will be than shrinked as much as possible.Many functions and variables name will be replaced with shrinked form that nobody can decode or understand at all :)

More details are here: https://developer.android.com/studio/build/shrink-code.html

Note that enabling ProGuard takes build time much more than normal build time.So better to do it before release of your app.



Related Topics



Leave a reply



Submit