How to decompile Android APK

How to decompile Android APK

Preface

I have been decompiling for a long time, but I picked it up again because I knew I had to do it today. I will record it today.

Tool Preparation

1. Test environment:

win10

2. Tools used:

2.1 Download address on CSDN:

apktool

dex2jar

jd-gui

2.2 Official latest version download address:

apktool(google code)

dex2jar(google code)

jd-gui (google code)

Tool Introduction

apktool

Function: Get resource files, you can extract image files and layout files for viewing.

dex2jar

Function: Decompile apk into Java source code (convert classes.dex into jar file)

jd-gui

Function: View the jar file converted from classes.dex in APK, that is, the source code file

Decompilation process

1. Decompile apk to get the source code, pictures, XML configuration, language resources and other files of the program

1) Download apktool from the above tools, decompress it to get 3 files: aapt.exe, apktool.bat, apktool.jar, put the APK file to be decompiled in this directory,

2) Open the command line interface (Run - CMD), locate the apktool folder, and enter the following command: apktool.bat d -f fish.apk fish

(In the command, test.apk refers to the full name of the APK file to be decompiled, and test is the name of the directory where the decompiled resource files are stored, that is: apktool.bat d -f [apk file] [output folder])

3) It means the acquisition is successful. Then you will find a fish file in the folder. Click it to view all the resource files of the application.

4) If you want to repackage the decompiled file into apk, you can: enter apktool.bat b test (your compiled folder), the effect is as follows:

5) Then you can find two more folders under the previous test file:

  • build
  • dist (which contains the packaged APK file)

2. Decompile Apk to get Java source code

1) Download dex2jar and jd-gui from the above tools and unzip them

2) Change the APK extension to .rar or .zip, and decompress it to get the classes.dex file (it is compiled from the java file and packaged by the dx tool). Put the obtained classes.dex into the dex2jar-0.0.9.15 folder of the tool that was decompressed before.

3) In the command line, locate the directory where dex2jar.bat is located and enter dex2jar.bat classes.dex. The effect is as follows:

4) A classes_dex2jar.jar file will be generated in this directory, then open the jd-gui.exe in the jd-gui folder, and then use the tool to open the previously generated classes_dex2jar.jar file, and you can see the source code. The effect is as follows:

5) Obfuscated renderings (class file names and method names inside them are named in a, b, c, etc.)

Decompilation status

Since the existence of this kind of tool is very detrimental to the protection of intellectual property rights, the current technology has also changed. Many companies will set up their own products, and various exceptions may occur during decompilation, resulting in decompilation failure.

<<:  Responsive Image Processing in Web Development

>>:  Developer’s statement: This is how I learned GAN

Recommend

Oneplus 6 in-depth review: the muscular "suit thug"

OnePlus 6 is a flagship product with high perform...

Qutoutiao advertising cases and advertising forms, advertising effects!

The editor will introduce to you the advertising ...

Analysis of 14 excellent case strategies in 7 major information flow industries!

This article shares with you excellent case analy...

Three major fissions of mobile Internet for free traffic!

After sharing the four major mobile Internet thin...

A family member is suddenly diagnosed with cancer, what can we do for them?

It is inevitable that relatives, friends, and acq...

The basics you need to know about HTML5

[[206162]] HTML5 is the fifth and current version...

Beidou Navigation: The “Savior” and “Helper” of the Navigation Industry

Since the first artificial satellite was launched...

What issues do you need to consider when you first start UI design?

For newcomers who are new to the UI field, in add...

Acea: EU new car registrations fell by 2.6% in January 2025

In January 2025, new car registrations in the EU ...

Scrcpy open source Android device control tool

Scrcpy is a powerful open source Android device c...

Why does China's most festive fruit unify the winters of the north and south?

Every winter, if there is no hawthorn, it seems i...