Android code obfuscation Summary

Source: Internet
Author: User

Add the default. properties file:

Target = Android-7
Proguard. Config = proguard. cfg

The above two sentences

Proguard. cfg file:

-Optimizationpasses 7

-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

<! -- Add the following section after using Baidu API -->
-Keep class com. Baidu. mapapi .**{*;}

-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 class * extends Android. App. Activity {
Public void * (Android. View. View );
}

-Keepclassmembers Enum *{
Public static ** [] values ();
Public static ** valueof (Java. Lang. String );
}

-Keep class * implements Android. OS. parcelable {
Public static final Android. OS. parcelable $ creator *;
}

-Keep public class * extends Android. View. View {
Public <init> (Android. content. context );
Public <init> (Android. content. Context, Android. util. attributeset );
Public <init> (Android. content. Context, Android. util. attributeset, INT );
Public void Set *(...);
}

-Keepclassmembers class **. r$ *{
Public static <fields>;
}

<! -- The following section must be used after serialization -->
-Keepnames class * implements java. Io. serializable

-Keepclassmembers class * implements java. Io. serializable {
Static final long serialversionuid;
Private Static final java. Io. objectstreamfield [] serialpersistentfields;
! Static! Transient <fields>;
Private void writeobject (Java. Io. objectoutputstream );
Private void readobject (Java. Io. objectinputstream );
Java. Lang. Object writereplace ();
Java. Lang. Object readresolve ();
}

Add:
 

-Dontwarn com. Google. Android. GCM .**

-Dontwarn net. nend. Android .**

-Dontwarn com. Google. Ads .**

You can also use this method to solve the unobfuscated problem after using a third-party package. The possible exception is:

Note: There were 160 duplicate class definitions.

Warning: COM. Google. Ads. M: Can't Find referenced class com. Google. Ads. Internal. state. adstate

Warning: COM. Google. Ads. M: Can't Find referenced class com. Google. Ads. Internal. state. adstate

You shoshould check if you need to specify additional program jars.

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.