Reference:
Http://www.cnblogs.com/sunzn/archive/2013/03/06/2946952.html
Http://www.apkbus.com/android-240707-1-1.html
1, found in the project root directory project.properties file, will be in the circle of code comments removed, that is to declare our confusion file for proguard-project.txt:
2. Locate the Proguard-project.txt file in the project root directory and add the following code as required:
# Specifies the compression level of the Code-optimizationpasses AA does not use case blending-dontusemixedcaseclassnames# does not confuse third-party jars -dontskipnonpubliclibraryclasses# obfuscation-dontpreverify# the algorithm used to log-verbose# confusion when the error is not pre-validated-optimizations!code/ Simplification/arithmetic,!field/*,!class/merging/*# affirms that the external jar package is not confused-libraryjars libs/alipay.jar# does not need to be confused, Classes such as system components and APIs:-keep public class * extends Android.app.fragment-keep public class * extends Android.app.activity-keep Publ IC class * extends Android.app.application-keep public class * extends Android.app.service-keep public class * extends and Roid.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 * Extends android.support.v4.**# The default Proguard checks that each reference is correct, but the third-party library often does not use a class # that is not properly referenced. If not configured, the system will error-dontwarn Android.support.**-dontwarn Com.alibaba.fastjson.**-dontwarn org.eclipse.persistence.**-dontwarn Com.amap.api.**-dontwarn javax.persistence.**# The specified class member is reserved-keepclassmembers class * extends android.app.Activity {public void * (Android.view.View);}
3, the above Comment said quite detailed, but the important is the following points:
(1) the jar packages stated here can only be referenced in this project, and the jar packages in other projects referenced by the project do not need to be stated in this confusing file:
# DECLARE external jar packages not to be confused-libraryjars Libs/alipay.jar
(2) The following statement needs to be added according to the jar package referenced in your project, for example, I just do not add, directly export the APK file, then in the console we can see the error message, and then add the error class path, such as com.amap.api.** is to affirm that com.amap.api.xxx are not to be confused:
# The default Proguard checks to see if each reference is correct, but the third-party library often does not use a class # that is not properly referenced. If not configured, the system will be error-dontwarn Android.support.**-dontwarn Com.alibaba.fastjson.**-dontwarn org.eclipse.persistence.**- Dontwarn Com.amap.api.**-dontwarn javax.persistence.**
4, finally, is confused after the anti-compilation to see the results, where the class name, method name, variable name, are automatically confused to others can not understand the name:
Code obfuscation for app security