The hard drive on my laptop just crashed and I lost all the source code for an app that I have been working on for the past two months. All I have is the APK file that is st
I'll show you other way to decompile the .apk files.
You can follow the first 2 steps from "prankul garg". So you have another opportunities:
Step 3':
Download the "JD-GUI", thats easy to found this one. Open your .jar file in "jd-gui.exe". (File > Open file > 'found your .jar file'). After this procedure, you can save all resources in a .zip file.
So,
1st - You have to rename the .apk file to .zip
2nd - You have to decode .dex file (if you want, decode the .apk file to dex2jar, that's possible)
3rd - You have to decode .jar file with JD-GUI
You can try DexPatcher. It even integrates with Android Studio. It uses Apktool and Dex2Jar internally.
You can use those tools independently as well.
Apktool decompiles apk, and extracts .dex files, which can further be converted to jar using Dex2Jar. Jar can be decompiled by using JD-GUI. You can see the Java code with the help of that tool. Although the similarity of decompiled code to the actual code cannot be guaranteed. There are some advanced code obfuscation tools available in the market, which mess up the code to make it difficult to decompile / understand. eg. Proguard
There's an app for that and generally takes just a few clicks and you are done. https://github.com/Nuvolect/DeepDive-Android
After that you can browse the source code, download it to another computer with elFinder or search through it using Lucene.
In addition to Jadx it has CFR and Fernflower decompilers.
This is an alternative description - just in case someone got stuck with the description above. Follow the steps:
apktool.jar
and put both files in the same foldercmd.exe
) and change into that folder; verify that a Java Environment is installed (for Linux check the notes regarding required libraries as well)apktool decode [apk file]
Intermediate result: resource files, AndroidManifest.xml
Intermediate result: classes.dex
dex2jar-0.0.9.15.zip
from http://code.google.com/p/dex2jar/downloads/detail?name=dex2jar-0.0.9.15.zip&can=2&q=classes.dex
onto dex2jar.bat
(or enter <path_to>\dex2jar.bat classes.dex
in a DOS box; for Linux use dex2jar.sh
)
Intermediate result: classes_dex2jar.jar
classes_dex2jar.jar
(might be optional depending on used decompiler)Result: source code
Note: it is not allowed to decompile third party packages; this guide is intended to recover personal source code from an APK file only; finally, the resulting code will most likely be obfuscated
There are a few ways to do this:
Use the "Profile or Debug APK" feature in Android Studio 3.0.
It allows you to open and explore APKs in Android Studio. Classes are decompiled into smali. Resources are not extracted and things like "Go to Definition", "Find All References" and debugging don't work without the source code (android studio 3.0 canary 9). Some additional smali features might work with smalidea.
Use jadx.
Jadx decompiles the code in a given APK to java source files.
Use apktool.
Apktool is a command line tool which extracts resources and decompiles code into smali for a given apk. You can recompile using apktool also. Here's an example of it in action:
$ apktool d test.apk
I: Using Apktool 2.2.4 on test.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: 1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
$ apktool b test
I: Using Apktool 2.2.4 on test
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
I: Building apk file...
I: Copying unknown files/dir...
This site https://www.apkdecompilers.com/ did it automatically.
I tried the site mentioned in the accepted answer first but that didn't work for me.