Decompiled code

To decomcompile the code in the APK file, we need to use the following two tools: dex2jar and JD-gui, which can be downloaded on the web. Here are the links to download them: dex2jar-2.0.zip and JD-GUi-Windows-1.4.0.zip

The dex2jar tool is used to convert dex files into JAR files. The JD-gui tool is used to convert JAR files into Java code

1. Decompress the toolkit

Download and unpack both tools, and we’ll decompile the Demo. When you unzip the Dex2JAR package, you’ll find a number of files, as shown below:

2. Decompress Demo.apk

Then we will decompress the Demo. Apk file. If you do not know how to decompress directly, you can rename the file to Demo.zip, and then open it with decompression software. When you unzip it, you’ll find a classes.dex file that looks like this:

3. Convert the classes.dex file to a JAR

Copy the classes.dex file to the decompressed dex2jar directory, open the CMD command window, switch to the decompressed dex2jar directory, enter the command: d2j-dex2jar classes.dex the execution result is as follows:

The classes-dex2jar. Jar file is the jar file that we successfully converted with the help of the tool. However, the JAR files are not readable to us either, so we need to use the JD-GUI tool again to convert the JAR files into Java code.

4. Open the DECOMpressed JD-GUI-Windows-1.4.0 file

Double-click to open the JD-gui.exe program, as shown in the figure

5. Drag the classes-dex2jar

The results are shown below:

OK


Decompile resources

Androidmanifest.xml file, res directory, AndroidManifest. Enter the RES directory, as shown below:

apktool

1. Tool download

Download address: ibotpeaches. Making. IO/Apktool/ins… Web disk address: pan.baidu.com/s/13_YUDVXx…

Bat and apkTool. jar files are all we need. The latest version of apkTool.jar is 2.3.1. Here I download the latest version, rename apkTool_2.3.1. jar to apkTool.jar, and put them in the same folder, as shown below.

2, decoding

The next step is to copy demo. apk to the same directory as these two files. Then CMD goes to the same directory and execute the following command: Apktool d demo. apk where D stands for decode, means that we want to decode the demo. apk file. So in addition to this basic usage, we can add some additional parameters to control more of decode’s behavior:

  • -f Deletes the existing folder forcibly if the target folder already exists. By default, the decoding fails if the target folder already exists.
  • -o specifies the name of the target folder to decode (by default, the target folder is named after the APK file).
  • -s does not decompile dex files, meaning that classes.dex files are kept (dex files are decoded into smali files by default).
  • -r does not decomcompile resource files, meaning that the resources.arsc file is retained (by default, resources.arsc is decoded into a specific resource file).

So that’s it. The result of the above command is as follows:

3. Error analysis

Of course, even if you are doing exactly the same operation as I did, you may still fail to decomcompile here, for example, you may get the following error:

If you think it works for you, give it a thumbs up