Obfuscation packaging for Android apps sharing _android

Source: Internet
Author: User
Tags map class

Obfuscation packaging for Android applications
1. Add the following proguard.config=proguard.cfg in the project.properties of the engineering document, as shown below:
Target=android-8

Proguard.config=proguard.cfg

Eclipse will generate proguard.cfg files in the engineering directory through this configuration

2. Generate KeyStore (if available for direct use)

Follow the command line below in the D:\Program files\java\jdk1.6.0_07\bin> directory, enter the Keytool-genkey-alias android.keystore-keyalg rsa-validity 100000-keystore Android.keystore

Parameter significance:-validity is mainly the validity period of the certificate, write 100,000 days, space, the BACKSPACE key is counted password.

After the command is executed, the Android.keystore file is generated in the D:\Program files\java\jdk1.6.0_07\bin> directory.

3. Operation in ECLIPCE

File-> Export-> export Android application-> Select Project-> Using the existing keystore, and input Pass Word-> Select the destination APK file

After confusing the source code, the original class name and method name will be similar to a,b,c ... , the principle of confusion is actually the mapping of class name and method name.

But the 4 large components are not confusing (all components defined in the manifest file cannot be confused) because the system needs to find and run the application through the manifest file.

Proguard.cfg File Code Interpretation

-optimizationpasses 5-> Set a confusing compression ratio of 0 ~ 7

-dontusemixedcaseclassnames-> AA AA

-dontskipnonpubliclibraryclasses-> If the application introduces a jar package and wants to confuse the class inside the jar bag

-dontpreverify

Mapping of Map class name-> transformation after-verbose-> confusion of production mapping file

-optimizations!code/simplification/arithmetic,!field/*,!class/merging/*-> is used to confuse the algorithm.

-keep public class * extends android.app.Activity-> All activity subclasses don't confuse

-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>; -> all the native methods cannot be confused.

}

-keepclasseswithmembers class * {

Public <init> (Android.content.Context, Android.util.AttributeSet);

--> Some construction methods cannot be confused.

}

-keepclasseswithmembers class * {

Public <init> (Android.content.Context, android.util.AttributeSet, int);

}

-keepclassmembers class * extends Android.app.Activity {

public void * (Android.view.View);

}

-keepclassmembers enum * {-> enum class cannot be confused.

public static **[] values ();

public static * * VALUEOF (java.lang.String);

}

-keep class * Implements android.os.Parcelable {-> Aidl file cannot be confused.

public static final Android.os.parcelable$creator *;

}

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.