banner
lca

lca

真正的不自由,是在自己的心中设下牢笼。

How to decompile an APK on macOS to view its source code

Tools Needed

Check apktool version

image

Install dex2jar on Mac

Step 1: Decompiling APK file with Apktool

image

From apktool, you can view some source code files of the apk. By using this method, you can only view smali source code.

image.png

Step 2: Decompiling dex to jar with dex2jar

Change the file extension of the apk to zip.

image

Extract the zip file to get the file with dex extension, then use dex2jar to convert the dex file to jar file.

image

Alternatively, you can directly download dex2jar, and then execute

If the compilation fails and displays a version issue, you need to modify the version in the dex file header.

image

The magic field in the dex file header is an 8-byte fixed character array that represents the type and version of the dex file. The following are the contents of the magic field in the dex file header for different versions:

• Android 1.0 and 1.1: dex 035
• Android 1.5: dex 035
• Android 1.6: dex 036
• Android 2.0 to 2.3.7: dex 035
• Android 3.0 to 3.2.6: dex 036
• Android 4.0 to 4.0.4: dex 035
• Android 4.1 to 4.4.4: dex 036
• Android 5.0 to 6.0.1: dex 037
• Android 7.0 to 7.1.2: dex 038
• Android 8.0 and above: dex 039

After obtaining the jar file, you can use jd-gui to view the jar code.

Step 3: Viewing jar code with JD-GUI

image

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.