Decompile apk in Mac environment and decompile apk in Mac Environment

Source: Internet
Author: User

Decompile apk in Mac environment and decompile apk in Mac Environment
0. Tool Summary

Decompiling apk mainly uses the following three tools:

  • Apktool: used to obtain resource files
  • Dex2jar: Get the source file jar package
  • JD-GUI: decompile source file jar package view source code
I took some time to find these tools. Now I have put all the final available versions I found on Baidu cloud. Download from the following link: http://pan.baidu.com/s/1qWDmf2O

1. apktool obtains the resource file
Apktool actually has more than one file, including aapt, apktool, and apktool. jar,



In the end, the command lines we call are all apktool, and the other two files depend on the tool. Copy the three files to the directory/usr/local/bin. Then you can use the apktool command line to check the detection effect.


Next, you can decompile your apk to obtain the resource file. First, use the command line to switch to the directory of your apk, and then execute the command
apktool d xxxx.apk
When I first run the above command, I encountered a problem, And someone on the Internet also encountered it.


The final problem was that the apktool. jar version of the three files in apktool was too low. Finally, I downloaded the latest version and replaced it. The problem was solved, and the final running effect was as follows:


After the preceding command is executed normally, you will find that a folder with the same name as the apk will be generated in the current directory, which contains the resource files generated by decompilation. This is where apktool is used.
2. dex2jar
First, change your apk file to the zip file format, and decompress it. There will be a classes. dex file, and then we will get the source file from this file. Copy the classes. dex file to your dex2jar folder and call the d2j-dex2jar.sh for decompilation. You may encounter the following problems:


This problem is very common in mac. Use the following command to solve it:
sudo chmod 777 d2j-jar2dex.sh
The d2j-jar2dex.sh may also depend on other. sh files in the same directory, and you may need to execute the above command for other. sh files (the d2j_ivoke.sh in it also needs to execute the following command ).
After solving the problem above, we can actually start decompiling to get the original file. Use the following command
./d2j-dex2jar.sh classes.dex

As follows:


After the command is executed, the current directory will generate a classes-dex2jar.jar file, the jar package is the final source file jar package, we are the last step, the jar package decompilation to obtain the java File
3, The JD-GUI gets the java source file easily, you just need to open the classes-dex2jar.jar generated in the previous step in the JD-GUI. Generally, we can obtain all resource files, slices, and layout files, but the source files are confused.

Above!



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.