Easy Tutorial
❮ Filter Filterchain Filterconfig Intro Javascript Toolbox ❯

1.11 Decompiling APK to Obtain Code & Resources

Category Android Basic Beginner Tutorial

Introduction to This Section

>

"Decompiling Apk," sounds sophisticated, but it's not. It involves using certain decompiling software to decompile our APK, thereby obtaining the program's source code, images, XML resources, and other files. Have you ever done this? Seeing someone else's app interface beautifully designed or liking their image assets, a simple way is to download their APK, change the file extension to xxx.zip, and then unzip it: The author unzipped an APK randomly:

>

We can open the res directory to get the image assets.

>

However, this method will only get bitmap files like .png or .jpg. If we want to view XML resources, they will appear as gibberish, and if we want to see the APK program's Java code, that won't work either, as they are all packaged into the classes.dex file! But decompiling can meet your needs. Also, do not use decompiling for illegal activities, such as repackaging someone else's APK with your signature and then publishing it to relevant markets... We are referring to others' code, not copying it entirely! Remember!

1. Three Tools to Prepare

>

-apktool: Retrieve resource files, extract image files, layout files, and some XML resource files.

-dex2jar: Decompile APK into Java source code (convert classes.dex into a jar file).

-jd-gui: View the jar file converted in step 2, i.e., view the Java files. For the convenience of readers, the three tools are bundled together and placed in the cloud drive. Those in need can download them: Three Decompiling Tools.zip


2. Using apktool to Decompile APK for Images and XML Resources:

>

After decompressing the downloaded apktool, we can see the following files (ignoring the two csdn files, one is the decompiled apk, and the other is the decompiled file):

apktool.bat d csdn.apk and press Enter:

Then you can see the generated csdn folder, which contains the resources we want.


3. Using dex2jar to Convert classes.dex into a jar File:

>

Decompress the downloaded dex2jar folder, copy the classes.dex from the decompressed apk to the directory where dex2jar.bat is located:

Open cmd, go to this directory, and type: d2j-dex2jar.bat classes.dex

Then we can see a jar package generated:


4. Using jd-gui to View Java Code in the jar Package:

>

Open the jd-gui folder,

Open the jar package converted in step 3, and we can see the code inside:


Summary of This Section

>

Well, the decompiling of APKs is introduced here. I believe you are eager to try it out. Go ahead and give it a try. Finally, a reminder: don't do anything bad! Respect others' labor! Also, the environment setup and some common development techniques in the first chapter are over. Starting from the next section, we will begin the second chapter of this tutorial series—learning about common UI controls in Android! Due to the large number of basic controls, it might be boring to learn them all at once, so I might write the tutorial in parallel, learning one control + a bit of other knowledge points every day. I need to think about it, stay tuned~ Thank you~

-1.0 Android Basic Beginner Tutorial

-1.0.1 2015 Latest Android Basic Beginner Tutorial Contents

-1.1 Background and System Architecture Analysis

-1.2 Development Environment Setup

-1.2.1 Using Eclipse + ADT + SDK to Develop Android APP

-1.2.2 Using Android Studio to Develop Android APP

-1.3 Solving SDK Update Issues

-1.4 Genymotion Emulator Installation

-1.5.1 Git Tutorial for Basic Local Repository Operations

-1.5.2 Git: Using GitHub to Build Remote Repository

-1.6 How to Play with the 9-Patch Image

-1.7 Interface Prototype Design

-1.8 Project Source Analysis (Various Files, Resource Access)

-1.9 Android Program Signing and Packaging

-2.1 Concepts of View and ViewGroup

-2.2.1 LinearLayout (Linear Layout)

-2.2.2 RelativeLayout (Relative Layout)

-2.2.3 TableLayout (Table Layout)

-2.2.4 FrameLayout (Frame Layout)

-2.2.5 GridLayout (Grid Layout)

-2.2.6 AbsoluteLayout (Absolute Layout)

-2.3.1 TextView (Text Box) Detailed Explanation

-2.3.2 EditText (Input Box) Detailed Explanation

-2.3.3 Button and ImageButton

-2.3.4 ImageView (Image View)

-2.3.5.RadioButton (Radio Button) & Checkbox (Checkbox)

-2.3.6 ToggleButton and Switch

-2.3.7 ProgressBar (Progress Bar)

-2.3.8 SeekBar (Drag Bar)

-2.3.9 RatingBar (Star Rating Bar)

-2.4.1 ScrollView (Scroll Bar)

-2.4.2 Date & Time Components (Part 1)

-2.4.3 Date & Time Components (Part 2)

-2.4.4 Adapter Basics

-2.4.5 Simple Usage of ListView

-2.4.6 BaseAdapter Optimization

-2.4.7 ListView Focus Issues

-2.4.8 Solving ListView Checkbox Misalignment Issues

-2.4.9 ListView Data Update Issues

-2.5.0 Building a Reusable Custom BaseAdapter

-2.5.1 Implementing Multi-Layout ListView Items

-2.5.2 Basic Usage of GridView (Grid View)

-2.5.3 Basic Usage of Spinner (List Option Box)

-2.5.4 Basic Usage of AutoCompleteTextView (Auto-Complete Text Box)

-2.5.5 Basic Usage of ExpandableListView (Collapsible List)

-2.5.6 Basic Usage of ViewFlipper (Flip View)

-2.5.7 Basic Usage of Toast

-2.5.8 Detailed Explanation of Notification (Status Bar Notification)

-2.5.9 Detailed Explanation of AlertDialog (Dialog Box)

-2.6.0 Basic Usage of Other Common Dialogs

-2.6.1 Basic Usage of PopupWindow (Floating Box)

-2.6.2 Menu

-2.6.3 Simple Usage of ViewPager

-2.6.4 Simple Usage of DrawerLayout (Official Side Menu)

-3.1.1 Event Handling Mechanism Based on Listening

-3.2 Event Handling Mechanism Based on Callback

-3.3 Analysis of Handler Message Passing Mechanism

WeChat Subscription

❮ Filter Filterchain Filterconfig Intro Javascript Toolbox ❯