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:
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 (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:
Now extract this .zip file in the same folder or a new folder.
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.
Move the classes.dex file into the dex2jar folder.
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.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.
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
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 the Command Prompt
Now run command
apktool if framework-res.apk
(if you don't have it get it here)and nextapktool 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
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 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:
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 (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:
Now extract this .zip file in the same folder or a new folder.
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.
Move the classes.dex file into the dex2jar folder.
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.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.
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
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 the Command Prompt
Now run command
apktool if framework-res.apk
(if you don't have it get it here)and nextapktool 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.
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
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
Android Gradle: Buildtoolsversion VS Compilesdkversion
How to Get a Jacoco Coverage Report Using Android Gradle Plugin 0.10.0 or Higher
React-Native, Android, Genymotion: Adb Server Didn't Ack
How to Implement an Android:Background That Doesn't Stretch
Adding Fling Gesture to an Image View - Android
Android: How Get the Status-Code of an Httpclient Request
How to Generate 11 Char Hash Key for Sms Retriever with Google App Signing
Up Navigation Broken on Jellybean
Extending Relativelayout, and Overriding Dispatchdraw() to Create a Zoomable Viewgroup
Determine When a Viewpager Changes Pages
Remove Vertical Padding from Horizontal Progressbar
Getting "Debuggable" Value of Androidmanifest from Code
How to Import Eclipse Project to Android Studio
[Install_Failed_No_Matching_Abis: Failed to Extract Native Libraries, Res=-113]
Android L (API 21) - Java.Lang.Illegalargumentexception: Service Intent Must Be Explicit