Is there a way to get the source code from an APK file?
Simple way: use online tool https://www.decompiler.com/, upload apk and get source code.
Procedure for decoding .apk files, step-by-step method:
Step 1:
Make a new folder and copy over the .apk file that you want to decode.
Now rename the extension of this .apk file to .zip (e.g. rename from filename.apk to filename.zip) and save it. Now you can access the classes.dex files, etc. At this stage you are able to see drawables but not xml and java files, so continue.
Step 2:
Now extract this .zip file in the same folder (or NEW FOLDER).
Download dex2jar and extract it to the same folder (or NEW FOLDER).
Move the classes.dex file into the dex2jar folder.
Now open command prompt and change directory to that folder (or NEW FOLDER). Then write
d2j-dex2jar classes.dex
(for mac terminal or ubuntu write./d2j-dex2jar.sh classes.dex
) and press enter. You now have the classes.dex.dex2jar file in the same folder.Download java decompiler, double click on jd-gui, click on open file, and open classes.dex.dex2jar file from that folder: now you get class files.
Save all of these class files (In jd-gui, click File -> Save All Sources) by src name. At this stage you get the java source but the .xml files are still unreadable, so continue.
Step 3:
Now open another new folder
Put in the .apk file which you want to decode
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
Open a command window
Now run command like
apktool if framework-res.apk
(if you don't have it get it here)and nextapktool d myApp.apk
(where myApp.apk denotes the filename that you want to decode)
now you get a file folder in that folder and can easily read the apk's xml files.
Step 4:
It's not any step, just copy contents of both folders(in this case, both new folders) to the single one
and enjoy the source code...
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
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 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.
Download dex2jar tool from dex2jar.
Use the tool to convert the APK file to JAR:
Windows:$ d2j-dex2jar.bat demo.apk
dex2jar demo.apk -> ./demo-dex2jar.jarMacOS / Linux:
$ d2j-dex2jar.sh -f demo.apk -o demo.jar
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:
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
How to extract code of .apk file which is not working?
Any .apk file from market or unsigned
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.Download Dex2Jar zip from this link: SourceForge
Unzip the downloaded zip file.
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)http://jd.benow.ca/ download decompiler from this link.
Open ‘targetapp.apk.dex2jar.jar’ with jd-gui
File > Save All Sources to sava the class files in jar to java files.
Get source code of my installed Android app
You have to access your android device via terminal to get the APK from it.
Moreover you'll need to root the device if the app has been installed from the app store. Once you got the APK you can decompile it in java code.
Root your device: http://www.digitaltrends.com/mobile/how-to-root-android/
Get the APK from the phone:
- Connect the phone to your computer and open a terminal.
- Run
adb shell
so you get into your phone. - Run
find /data/app -name '*.apk'
to list the apks installed and copy the name of the one in your interest. - Run adb pull /data/app/appname.apk
Now that you have the APK on your computer you have to decompile the APK.
Flutter debug Apk decompile to get the source code
If your debug.apk is in debug mode then you can use apktool
in order to extract the components of the apk
(I'm using the word extracting since apk
is a zip file).
Flutter, in debug mode, keeps the source code (with comments!) in the file kernel_blob.bin. Thus, using the following command should help you extract the code into a file:
strings /path/to/extracted/apk/assets/flutter_assets/kernel_blob.bin > extracted_code.dart
Please, pay attention - You'll need to clean 'extracted_code.dart', from irrelevant/garbage strings.
Try to search strings like "dart", "import", "void" and other keywords in 'extracted_code.dart', it will help you find the code itself.
Here's an example from my Ubuntu:
If the apk
is compiled in "release" mode, extracting the code will be much harder, since the code is compiled into isolate_snapshot_instr file, which is not a raw arm assembly, and is only deserialized using the Flutter engine in run-time. You can read more about it here
Is there a way to get the source code from an APK file?
Simple way: use online tool https://www.decompiler.com/, upload apk and get source code.
Procedure for decoding .apk files, step-by-step method:
Step 1:
Make a new folder and copy over the .apk file that you want to decode.
Now rename the extension of this .apk file to .zip (e.g. rename from filename.apk to filename.zip) and save it. Now you can access the classes.dex files, etc. At this stage you are able to see drawables but not xml and java files, so continue.
Step 2:
Now extract this .zip file in the same folder (or NEW FOLDER).
Download dex2jar and extract it to the same folder (or NEW FOLDER).
Move the classes.dex file into the dex2jar folder.
Now open command prompt and change directory to that folder (or NEW FOLDER). Then write
d2j-dex2jar classes.dex
(for mac terminal or ubuntu write./d2j-dex2jar.sh classes.dex
) and press enter. You now have the classes.dex.dex2jar file in the same folder.Download java decompiler, double click on jd-gui, click on open file, and open classes.dex.dex2jar file from that folder: now you get class files.
Save all of these class files (In jd-gui, click File -> Save All Sources) by src name. At this stage you get the java source but the .xml files are still unreadable, so continue.
Step 3:
Now open another new folder
Put in the .apk file which you want to decode
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
Open a command window
Now run command like
apktool if framework-res.apk
(if you don't have it get it here)and nextapktool d myApp.apk
(where myApp.apk denotes the filename that you want to decode)
now you get a file folder in that folder and can easily read the apk's xml files.
Step 4:
It's not any step, just copy contents of both folders(in this case, both new folders) to the single one
and enjoy the source code...
Related Topics
How to Retrieve Data from Firebase to My Adapter
How to Enable Multidexing With the New Android Multidex Support Library
How to Send Emails from My Android Application
How to Resize a Bitmap in Android
Android Studio Installation on Windows 7 Fails, No Jdk Found
How to Build a Horizontal Listview With Recyclerview
How to Validate an E-Mail Address
"Failed to Load Ad: 3" With Doubleclick
Android Studio: Add Jar as Library
Firebase Android: Make Username Unique
Simple Android Recyclerview Example
Notification Not Showing in Oreo
Android - Dynamically Add Views into View
Android Studio Suddenly Cannot Resolve Symbols