Android apk anti-compiler graphics tutorial _android

Source: Internet
Author: User

In learning the Android development process, you tend to learn how other people's apps are developed, and those beautiful animations and exquisite layouts may put you down, as a developer, you might want to know how these effects interfaces are implemented, You will be able to reverse-compile the application of the APK view. Below is a few articles I refer to after a simple tutorial detailed.

(Note: Anti-compilation is not to let developers go to an application cracked to reload what, the main purpose is to promote developers to learn, learn from good code, improve the level of self-development.) )

Test environment:

Win 7

Use tools:

Cloud-dwelling community Download address:

Apktool (resource file get) Download

Dex2jar (source file acquisition) download

Jd-gui (source view) Download

Official latest version Download address:

Apktool (google code)

dex2jar(google code)

Jd-gui (google Code) The latest edition, please see the official

Tools Introduction:

Apktool

Function: Resource file Get, can extract picture file and layout file for use view

Dex2jar

Role: APK to Java source code (Classes.dex into a jar file)

Jd-gui

Role: View the apk classes.dex into the jar file, that is, the source file

Reverse Compile process:

APK the source Code of the program, picture, XML configuration, language resources and other documents

Download the Apktool in the above tool, extract 3 files: Aapt.exe,apktool.bat,apktool.jar, put apk files that need to be decompile into the directory,

Open the Command line interface (run-cmd) , navigate to the Apktool folder, and enter the following command:apktool.bat d-f test.apk test


(in the command, test.apk refers to the full name of the APK file you want to decompile, test is the directory name that is stored in the decompile resource file, that is: Apktool.bat d-f [apk file] [output folder])

Description of the success, then found in the folder under a test file, click on the application can view all the resource files.

If you want to repackage the precompiled files into APK, you can: Enter apktool.bat B Test(you compile the folder) to be able to, the effect is as follows:


After that, you can find 2 more folders in the previous test file:

Build

Dist (it's packed with apk files)

Second, apk to get the Java source code

Download the Dex2jar and Jd-gui in the above tools to extract

Change the apk suffix name to. rar or. zip, and extract the amount of the Classes.dex file (which is the Java file compilation and then packaged with the DX tool) to get the Classes.dex is placed in the dex2jar-0.0.9.15 folder of the previously extracted tools,

At the command line, navigate to the directory where Dex2jar.bat is located, enter Dex2jar.bat Classes.dex, and the effect is as follows:

A Classes_dex2jar.jar file is generated in the modified directory , then the Jd-gui.exe in the tool Jd-gui folder is opened, and then the generated Classes_ is opened with the tool Dex2jar.jar file, you can see the source code, the effect is as follows:

The confusing effect chart (the name of the class file and the name of the method inside) will be a,b,c .... And so on, named after the style):


Third, the graphical reverse compiles the APK (I have not used)

Step one or two above describes the command line Decompile APK and now provides a graphical decompile tool: Androidfby

First, download the Decompile toolkit above, open the Androidfby directory, double-click the Android decompile tool. exe to open the APK that you want to reverse compile.

By recompiling, you can learn what the application uses for the 3rd party library file, how its code is written, and so on.

However, if the apk is confused, the name of the class file you see and the method name inside will be a,b,c .... Style naming, so you can find that you want to know the interface code may be very difficult to find the code may also look very laborious, but a general idea will be obtained, with this idea, you can try it yourself.

I once wanted to write a similar singing of the celebrity interface layout, but the first contact does not know how to write, into the decompile, even if his code is confused, I also see that he is through the ListView type set different item layout realized. Maybe a lot of references are implemented by rewriting view, you can get his general ideas for your development is beneficial.

There is also a developer working hard to develop their own applications to be a reverse compilation of his own things, so to be confused

As Android application developers, have to face an embarrassing situation, is their own hard to develop the application can be easily compiled by others.

Google also seems to have found the problem, starting with SDK2.3 we can see a Proguard folder under Android-sdk-windows\tools\

Proguard is a Java code obfuscation tool, through Proguard, others even decompile your APK package, will only see some difficult to understand the code, so as to protect the role of the Code.

The following specifically say how to let SDK2.3 under the Proguard.cfg file work, first look at the contents of Android-sdk-windows\tools\lib\proguard.cfg:

-optimizationpasses 5-dontusemixedcaseclassnames-dontskipnonpubliclibraryclasses-dontpreverify-verbose-optimiza tions!code/simplification/arithmetic,!field/*,!class/merging/*-keep public class * extends Android.app.activity-kee P public class * extends Android.app.application-keep public class * extends Android.app.service-keep public class * E  Xtends Android.content.broadcastreceiver-keep public class * extends Android.content.contentprovider-keep public class * Extends Android.app.backup.backupagenthelper-keep public class * extends Android.preference.preference-keep public 
Class Com.android.vending.licensing.ilicensingservice-keepclasseswithmembernames class * {native <methods>; 
}-keepclasseswithmembernames class * {public <init> (Android.content.Context, Android.util.AttributeSet); }-keepclasseswithmembernames class * {public <init> (Android.content.Context, android.util.AttributeSet, int) 
; }-keepclassmembers Enum * {public static **[] values (); 
public static * * VALUEOF (java.lang.String); 
}-keep class * Implements android.os.Parcelable {public static final android.os.parcelable$creator *; 
 }

As you can see from the script, the confusion retains the inheritance from the activity, Service, application, Broadcastreceiver, ContentProvider and other basic components, as well as Com.android.vending.licensing.ILicensingService,

All the native variable names and class names are retained, and all classes are partially set up with a fixed parameter format constructor, enumeration, and so on. (For more information, refer to the examples and comments in <proguard_path>/examples.) )

The simple way to make proguard.cfg work is simply to add a "proguard.config=proguard.cfg" to the Default.properties file that eclipse automatically generates.

The complete default.properties file should read as follows:

# This file was automatically generated by Android Tools. 
# don't modify this file--YOUR CHANGES would be erased! 
# This 
file must is checked in Version control Systems. 
# to 
customize properties used by the ' Ant build system ' use, 
# ' Build.properties ', and override values to adapt T He script to your 
# project structure. 
 
# Project Target. 
Target=android-9 
proguard.config=proguard.cfg 

Done, the normal compilation of signatures can prevent the code from being decompile.

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.