In order to prevent the results of their own work stolen by others, confusing code can effectively prevent the anti-compilation
1. It may be noted that a new project will see the project under the Proguard-project.txt a file, which is very important for confusing code, if you accidentally deleted it, it's okay, copy one from somewhere else.
2. The most important thing is to add the confusing statement to the Proguard-project.txt:
A. Declare all your jar packages, for example:
-libraryjars Libs/apns_1.0.6.jar
-libraryjars libs/armeabi/libbaidumapsdk_v2_3_1.so
-libraryjars libs/armeabi/liblocsdk4.so
-libraryjars Libs/baidumapapi_v2_3_1.jar
-libraryjars Libs/core.jar
-libraryjars Libs/gesture-imageview.jar
-libraryjars Libs/gson-2.0.jar
-libraryjars Libs/infogracesound.jar
-libraryjars Libs/locsdk_4.0.jar
-libraryjars Libs/ormlite-android-4.48.jar
-libraryjars Libs/ormlite-core-4.48.jar
-libraryjars Libs/universal-image-loader-1.9.0.jar
B. Make a statement that you do not need to confuse, because some of the classes that are confused can cause the program to compile without passing, as follows:
-keep public class * extends Android.app.Fragment
-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 * extends android.support.v4.**
-keep public class Com.android.vending.licensing.ILicensingService
--The above is the class in the API, it is best to avoid confusion
Some are very special, such as Baidu Map, you need to add the following statement:
-keep class com.baidu.** {*;}
-keep class vi.com.gdi.bgl.android.**{*;}
In my experience, it is best to avoid confusion in the general model (model is irrelevant, not confusing, not much) such as:
-keep class com.bank.pingan.model.** {*;}
The following is a statement about Umeng sharing statistics to avoid confusion
-dontwarn android.support.v4.**
-dontwarn org.apache.commons.net.**
-dontwarn com.tencent.**
-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 *;
}
-keepclasseswithmembers class * {
Public <init> (Android.content.Context);
}
-dontshrink
-dontoptimize
-dontwarn com.google.android.maps.**
-dontwarn Android.webkit.WebView
-dontwarn com.umeng.**
-dontwarn com.tencent.weibo.sdk.**
-dontwarn com.facebook.**
-keep enum com.facebook.**
-keepattributes exceptions,innerclasses,signature
-keepattributes *annotation*
-keepattributes sourcefile,linenumbertable
-keep public Interface com.facebook.**
-keep public Interface com.tencent.**
-keep public Interface com.umeng.socialize.**
-keep public Interface com.umeng.socialize.sensor.**
-keep public Interface com.umeng.scrshot.**
-keep public class Com.umeng.socialize.* {*;}
-keep public class javax.**
-keep public class android.webkit.**
-keep class com.facebook.**
-keep class com.umeng.scrshot.**
-keep public class com.tencent.** {*;}
-keep class com.umeng.socialize.sensor.**
-keep class Com.tencent.mm.sdk.openapi.WXMediaMessage {*;}
-keep class com.tencent.mm.sdk.openapi.** implements Com.tencent.mm.sdk.openapi.wxmediamessage$imediaobject {*;}
-keep class Im.yixin.sdk.api.YXMessage {*;}
-keep class im.yixin.sdk.api.** implements im.yixin.sdk.api.yxmessage$yxmessagedata{*;}
-keep public class [Your_pkg]. r$*{
public static final int *;
}
3. The above work is complete, the confusion work completes the more than half, the final need to do is to add your confused file in the Project.Properties file declaration, as follows:
Proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
4. OK, the final step, hit the signature package test, if there is a problem, look closely at the log may have a class can not be confused, then you have to add to the Proguard-project.txt file
-------above is the whole process of confusing the code.
Attention:
1. Project-dependent jar declarations:
The following are examples of messages sent
-libraryjars. /klowerbase/libs/mail-activation.jar
-libraryjars. /klowerbase/libs/mail-additionnal.jar
-libraryjars. /klowerbase/libs/mail.jar
2. Resolve the mail to send the Times with an exception
-keep class javax.mail.**{*;}
-keep class com.sun.mail.**{*;}
-keep class javax.activation.**{*;}
-keep class org.apache.harmony.**{*;}
-keep class java.security.**{*;}
#解决: Can ' t find referenced class Java.beans.Beans
-dontwarn Org.apache.commons.collections.BeanMap
-dontwarn java.beans.**
#解决: Can ' t find referenced class JAVAX.SECURITY.SASL.SASL
-dontwarn com.sun.mail.imap.protocol.**
(ext.) Android Eclipse Code obfuscation