- Decompile APK Get Java + Xml Change Apps
- Disclaimer
- Use Case
- Limitation
- Requirement
- Concepts & Overview
- Software Downloads & Installations
- #1: Get Source Code form APK JAVA + XML
- #2: Modify Apps Using APK Tool
- Neil Mahaseth
- .JAR and .Class to Java decompiler
- Java-Espresso
- Monday, February 20, 2012
- JAR to JAVA converter
- 2 comments:
Decompile APK Get Java + Xml Change Apps
Ever felt to change the look and feel of an app or did you accidentally delete your source code. See how to decompile apk to get the source code and how to customize any android app.
This guide is divided into two parts:-
- We will see how to decompile apk and extract the source code.
- Step by step how to make, look and feel changes to an Android app.
Disclaimer
This guide is purely for educational purpose. We encourage the users to go through the legality before using this guide on any real world application.
Use Case
- Recover accidentally deleted source code from the apk file
- Analysis of security vulnerability and threat detection
- Modding apps
- Add a new feature
- Customize the look and feel
- Support for non-supported android version
Limitation
- Cannot extract the exact same source code as originally written.
- Some part of the code might not be correctly retrieved.
- If the app uses a custom framework you will need the custom framework apk file.
- Most apps do not use custom frameworks.
Requirement
- Windows System
- Java Runtime Environment (JRE) 1.7
- http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jre-7u80-oth-JPR
- https://bitbucket.org/iBotPeaches/apktool/downloads
- https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/windows/apktool.bat
- https://github.com/pxb1988/dex2jar/releases/
- https://github.com/java-decompiler/jd-gui/releases/
- https://github.com/deathmarine/Luyten/releases
- https://play.google.com/store/apps/details?id=kellinwood.zipsigner2&hl=en
Concepts & Overview
- Apk file is a zip file.
- Zip file consists of XML and other android application resources.
- Apktools decodes the resource files and converts the android bytecode into assembly level samli files.
- Dex2jar converts the dex files into java bytecode file archived inside the jar file.
- JD GUI and Luyten decompiles java byte code to java source code file.
Software Downloads & Installations
Create Install Directory
Download and Install Apktools
- Download the latest version of Apktools jar file from the website given above.
- Copy apktool_x.y.z.jar into the newly created directory
- Rename apktool_x.y.z.jar to apktool.jar
- Right click and click on “save link as” on apktool.bat link
- Copy apktool.bat file in the same directory
Download and Install Luyten
- Go to Luyten website and download the latest release of luyten-x.y.z.exe
- Copy luyten-x.y.z.exe file in the same directory
Download and Install JD-GUI
- Go to JD-GUI website download the latest version of jd-gui-windows-x.y.z.zip
- Extract jd-gui-windows-x.y.z.zip file in the same directory
Download and Install Dex2jar
- Go to Dex2jar website download the latest stable release of dex-tools-y.x.zip
- Extract dex-tools-y.x.zip file in the same directory
- Rename d2j-dex2jar.bat to d2j
Download and Install JRE 1.7
- Download and install JRE 1.7 from the above link.
- In command prompt type Java – version this should show 1.7.
- Might show a higher version if your system has a newer version should still be fine.
Install Zip Signer App
Set the Path Environment Variable
- Open System Property
- In Windows 7
- Click on the start button.
- Right-click on Computer and select properties.
- Right-click on the start button.
- Select system properties.
Test Installed Software
- Open a new command prompt
- Click on start
- Type in cmd
- Then select cmd.exe
- Should print out 2.2
#1: Get Source Code form APK JAVA + XML
Download APK from Play Store
Decode APK Using Apktool
The second step is to use apk tools to decode the apk and extract Dex files and the resource files.
- Open command prompt
- Type cd “type here the location of the apk file” and press enter
- If the location is on a different drive then type the drive letter and then press enter.
- For apk with custom framework, install it by typing the command apktool if xyz.apk and hit enter (Optional)
- Replace xyz.apk with the name of your framework apk
- To decode your app apk file type in apktool d –m app.apk and hit enter
- Replace app.apk with the name of your application apk
The m option stands for match. This is usually done when you require the exact same resource files, but this prevents rebuilding the apk once you have modified it.
After decoding finishes find the decoded application resources in the same directory in a subfolder named after the application name.
Convert Dex to Jar using dex2jar
- Open command prompt
- Type d2j app.apk and hit enter
- Replace app.apk with the name of your application apk
Find the converted jar file in the same folder
Decompile Jar to Java Source Code
We will be using two applications to convert the jar file into Java code. We will be doing this because the conversion of android Dex code to a Java Jar file is not perfect and certain information is lost. This might lead to improper Java code from the jar file.
Using two applications provides alternate code for a particular file which was not decoded properly. So if for a particular file the code generated by the first application is not correct. Then we can check the code generated by the second application.
Decompile Jar to Java Source Code using JD-GUI
- Go to the installation directory and open jd-gui.exe.
- Select open a file go to the directory the jar file is present.
- Select the jar file and click open.
- Click on the file and click on Save All Sources.
- Select the directory where you want to save.
Decompile Jar to Java Source Code using Luyten
- Go to the installation directory and click on lyuten.exe
- Click on file and then click on Open File
- Select the directory where the jar file is saved and select the jar file
- Click on File and then click on Save All
- Select the location for saving the Java code
#2: Modify Apps Using APK Tool
Decode Pokemon GO APK Using Apktool
We will decode the apk file without using the m option. Since we now require to rebuild the application after modifying the required files.
- Open command prompt.
- Type cd “type here the location of the PokemonGo apk file” and press enter.
- If the location is on a different drive then type the drive letter and then press enter.
- To decode your app apk file type in apktool d PokemonGo.apk and hit enter
- Make sure to delete any previously decoded application in that folder.
Modify Pokemon GO Splash Screen
- Open the decoded PokemonGo apk folder.
- Click on the assets directory.
- Go to bin, then go to data.
- Search for the splash.png file in this directory.
- Open it using any image editor.
- Modify it in any manner I will overlap a cute Pikachu image over it.
- Save this modified splash screen by overwriting it on the original image.
Rebuild Pokemon Go Apk Using APkTool
- Open command prompt
- Type cd “type here the location of the PokemonGo apk file” and press enter.
- If the location is on a different drive then type the drive letter and then press enter.
- Type apktool b PokemonGo
Transfer Apk Using EZ File Explorer
- Open the EZ File Explorer app.
- Open the menu by tapping on the three lines icon on the top left corner.
- Tap on Network then on Remote Manager.
- Turn On FTP Server by tapping it.
- Open the phone storage by opening the file explorer and type the address shown in the EZ File Explorer app.
- Go to the directory with PokemonGo Apk File.
- Open PokemonGo directory and open dist folder.
- Copy the apk file in the dist folder.
- Paste it the phone storage.
Sign Apk Using Zip Signer App
- Open the zip signer app, tap on Input
- Select the apk file that you just copied to your phone
- Tap on sign the file
Install and Test Modified App
- Open the phone directory where you saved the apk file using EZ File Explorer
- Tap on the pokemongo-signed.apk it will install as an update to the app
- Tap install
- Open the Pokemon Go app you should see the modified splash screen.
I hope this guide helped you. If yes, consider supporting us. If you are facing some problem following this guide share it below in the comment section. We will try our best to resolve it. You can help others by sharing this guide with your friends whom you think could benefit from it.
Have some questions join the discussion.
Neil Mahaseth
Hello, friends welcome to HowISolve.com, a community founded by me in June 2015. With the aim to help you solve your everyday tech problems. The motivation for starting this community was instilled from my love for technology and my nature to help others in need.
By qualification, I am a technocrat with an M.B.A. and B.Tech. from Narsee Monjee, Mumbai. I have experienced both worlds: corporate and startup. I am currently honing my entrepreneurial skills and trying to add value to people’s lives.
You can also join us by subscribing to our Newsletters & YouTube channel to be a part of this growing community.
.JAR and .Class to Java decompiler
Until recently, you needed to use a Java decompiler and all of them were either unstable, obsolete, unfinished, or in the best case all of the above. And, if not, then they were commercial. The obsoleteness was typically proved by the fact that they can only decompile JDK 1.3 bytecode.
The only so-so working solution was to take the .class file and pre-process it, so it becomes JDK 1.3 compatible, and then run Jad over it (one of those older, but better decompilers).But recently, a new wave of decompilers has forayed onto the market: Procyon, CFR, JD, Fernflower, Krakatau, Candle.
Here’s a list of decompilers presented on this site:CFR
This free and open-source decompiler is available here: http://www.benf.org/other/cfr/
Author: Lee Benfield- Java 7: String switches
- Java 8: lambdas
- Java 9: modules
- Java 11: dynamic constants
- Java 12: Kotlin style «switch expressions»
- Java 14: ‘instance of’ pattern match and ‘Record types’
JD
free for non-commercial use only, http://jd.benow.ca/
Author: Emmanuel DupuyUpdated in 2015. Has its own visual interface and plugins to Eclipse and IntelliJ . Written in C++, so very fast. Supports Java 5.
Procyon
- Enum declarations
- Enum and String switch statements
- Local classes (both anonymous and named)
- Annotations
- Java 8 Lambdas and method references (i.e., the :: operator).
Fernflower
Updated in 2015. Very promising analytical Java decompiler, now becomes an integral part of IntelliJ 14. (https://github.com/JetBrains/intellij-community/tree/master/plugins/java-decompiler)
Supports Java up to version 6 (Annotations, generics, enums)JAD
given here only for historical reason. Free, no source-code available, jad download mirror
Author: Pavel KouznetsovProbably, this is the most popular Java decompiler, but primarily of this age only. Written in C++, so very fast.
Outdated, unsupported and does not decompile correctly Java 5 and later.Java-Espresso
Through this blog, I share my experiences, Problems that me and my team faced and how we resolved them. Apart from that Technical tips, tricks, Java Basics and also questions that are asked in interviews related to Java.
Now blog can be accessed from a direct URL www.java-espresso.inMonday, February 20, 2012
JAR to JAVA converter
I went through many websites,but i did not find any converter for jar file to .java files at one go.
So, I thought of writing a script for this conversion. This script also keeps the package structure same as in the jar file- This is restricted to windows platform
- Unzip utility should be installed in the system
- jad decompiler should be installed.
If you don’t have jad installed, you can find from the following link
click here to download - Unzip the jad.zip downlaoded in step2,set the jad.exe in the systems path variable.
- Run the command prompt in the administrator mode
- cd «path to which batch file is placed«
- jar2java.bat «jar file name/jar file path with jar file name» Note: Give jar file name without extension
Note:Remove the extention .txt to make it .bat file.
Example:
Step 1) >cd D:\jartojava (Copy the above downloaded batch file in this folder)
Step 2) jartojava> jar2java.bat abc (copy abc.jar in this folder)
Here a folder named abc is created with all the java files found in abc.jar.2 comments:
You can use this tool:
http://www.neshkov.com/ac_decompiler.html
AndroChef successfully decompiles obfuscated Java 6 and Java 7 .class and .jar files. It is simple but powerful tool that allows you to decompile Java and Dalvik bytecode (DEX, APK) into readable Java source. Reply DeleteI have read your blog its very attractive and impressive. I like it your blog.
Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 8 online training JavaEE Training in Chennai Java EE Training in Chennai Reply Delete