Detailed explanation and examples of Android confusion code

In order to prevent others from stealing their own labor achievements and effectively prevent the obfuscated code from being decompiled, the following steps of obfuscated code are summarized:

1. You may notice that when you build a new project, you will see such a project under the project Txt is a file, which is very important for confusing code. If you accidentally delete it, it doesn't matter. Copy it from other places

2. The most important is in the project guard project Txt adds a confusing statement:

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. Declare the parts you don't need to be confused, because some classes will fail to compile after being confused, 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 are all classes 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.** {*;}

According to my experience, it's best to avoid confusion for general models (model doesn't matter, and it doesn't matter if it's not confused), such as:

-keep class com. bank. pingan. model.** { *; }

Here is a statement about Umeng's 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. After the above work is completed, more than half of the confusion work is completed. The last thing to do is in project Add your confusion file declaration in the properties file, as follows: Proguard config=${sdk.dir}/tools/proguard/proguard-android. txt:proguard-project. txt

4. OK, the last step is to test the signature package. If there is a problem, take a closer look at the log. Maybe there are classes that can not be confused, then you have to join the Proguard project Txt file

-------This is the whole process of confusing code

Finally, paste Proguard project Txt full code:

Updated on May 25, 2015

1. Statement of reliance on the project:

The following is an example of mail sending

-libraryjars ../ KlowerBase/libs/mail-activation. jar -libraryjars ../ KlowerBase/libs/mail-additionnal. jar -libraryjars ../ KlowerBase/libs/mail. jar

2. Solve the exception of sending email

Through this article, I hope to help Android develop applications and use confused code. Thank you for your support for this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>