Android apk secure decompilation and simple anti-decompilation record

Source: Internet
Author: User

Decompilation and anti-Decompilation


The software I 've worked so hard to write is found to be copied by other unscrupulous programmers. What's more annoying is that it is also released to the market, causing inexplicable harm to my labor achievements and products. so, we should first learn the principle of decompilation and analyze how to prevent others from decompiling their own software.

I. How to decompile?


1. Download apktool and decompile the resource file to obtain the dpi images and media files of the project. You can see the AndroidManifest. xml configuration file.

1. Renewal

The folder includes apktool. jar, aapt, and apktool.

3../apktool d xxx.apk to generate the following:
AndroidManifest. xml apktool. yml assets lib res smali


2. Download dex2jar and decompile java code

1,: http://code.google.com/p/dex2jar/downloads/list

2../dex2jar. sh classes. dex (file in the original apk) to generate classes_dex2jar.jar


3. Download jd-gui. If the code is not protected, you can see the complete java source code.

1,: http://jd.benow.ca/
2. Open./jd-gui, import classes_dex2jar.jar, and save the source file.

Decompilation tool package download (decompress password: android ):

Http://download.csdn.net/detail/chang_xing/7140825


2. How can we prevent others from decompiling?


1. Use the method officially provided by android to confuse the code. (The main file must be project.propertiesand proguard-project.txt) 1. Under the project, project. propertiesFile to make the following changes

# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk. dir, user. home ):
Proguard. config =$ {sdk. dir}/tools/proguard/proguard-android.txt: proguard-project.txt

2, After modification, compile and release the file, decompile the apk in the above steps to view the file, and find that all files under the project are confused.


How to configure project Obfuscation? Use proguard-project.txt(In the old version, proguard. cfg is provided when a project is created, but there is no prompt for creating a project in the new version. In this case, you only need to add the content of proguard.txt to proguard-project.txt, and then edit it as needed.).

The following functions:

From the script, we can see that the obfuscation retains the basic components inherited from Activity, Service, Application, BroadcastReceiver, ContentProvider, and com. android. vending. licensing. ILicensingService,

All Native variable names and class names are retained. All classes Use constructors with fixed parameter formats, such as enumeration. (For more information, see examples and comments in <proguard_path>/examples .)


    -optimizationpasses 5      -dontusemixedcaseclassnames      -dontskipnonpubliclibraryclasses      -dontpreverify      -verbose      -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*            -keep public class * extends android.app.Activity      -keep public class * extends android.app.Application      -keep public class * extends android.app.Service      -keep public class * extends 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 *;      }  

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.