Code obfuscation for Android common third-party packages

Source: Internet
Author: User

First in: Project.Properties file, start code obfuscation

Proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt to cancel this line of comments.

Modify the Proguard-project.txt code to confuse the file.

1) Caution ignoring warnings

-ignorewarnings
-dontwarn

2) Note that using a class that is reflective requires a keep

-keepattributes Signature
-keepattributes *annotation*

3) Libs jar, all with-libraryjars libs/add to File

4) Armeabi, armeabi-v7a under So, through-libraryjars libs/armeabi/,-libraryjars libs/armeabi-v7a/Add File

## ----------------------------------
# # ########## A push to confuse ##########
## ----------------------------------

-dontwarn com.igexin.**
-keep class com.igexin.** {*;}

## ----------------------------------
# # ########## Gson Confusion ##########
## ----------------------------------
-keep class Sun.misc.Unsafe {*;}
-keep class com.google.gson.examples.android.model.** {*;}

## ----------------------------------
# # SHARESDK
## ----------------------------------

-keepattributes innerclasses,linenumbertable
-keep class Android.net.http.SslError
-keep class android.webkit.**{*;}
-keep class cn.sharesdk.**{*;}
-keep class cn.smssdk.**{*;}
-keep class com.mob.**{*;}

# # -------------------------------------------
# # ############### Volley confuse ###############
# # -------------------------------------------
-keep class com.android.volley.** {*;}
-keep class com.android.volley.toolbox.** {*;}
-keep class com.android.volley.response$* {*;}
-keep class com.android.volley.request$* {*;}
-keep class com.android.volley.requestqueue$* {*;}
-keep class com.android.volley.toolbox.hurlstack$* {*;}
-keep class com.android.volley.toolbox.imageloader$* {*;}

# # -------------------------------------------
# # ############### Slidingmenu confuse ###############
# # -------------------------------------------

-dontwarn com.jeremyfeinstein.slidingmenu.lib.**
-keep class com.jeremyfeinstein.slidingmenu.lib.**{*;}

# # -------------------------------------------
# # ############### Baidu confuse ###############
# # -------------------------------------------

-keep class com.baidu.mapapi.** {*;}
-keep class com.baidu.platform.** {*;}
-keep class com.baidu.location.** {*;}
-keep class com.baidu.vi.** {*;}
-keep class vi.com.gdi.bgl.android.** {*;}

# Universal-image-loader Confusion

-dontwarn com.nostra13.universalimageloader.**
-keep class com.nostra13.universalimageloader.** {*;}

-libraryjars Libs/android-support-v4.jar
# # -------------------------------------------
# # ############### Android-support-v4 confuse ###############
# # -------------------------------------------
-dontwarn android.support.v4.**
-keep class android.support.v4.** {*;}
-keep interface android.support.v4.app.** {*;}
-keep public class * extends android.support.v4.**
-keep public class * extends Android.app.Fragment

# # -------------------------------------------
# # ############### Androidannotations confuse ###############
# # -------------------------------------------

-dontwarn org.springframework.**

# # -------------------------------------------
# # ############### System API and other general confusion ###############
# # -------------------------------------------

-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.preference.Preference
-keep public class Com.android.vending.licensing.ILicensingService
-keep public class * extends Android.app.backup.BackupAgentHelper
-keep public class * extends Android.preference.Preference

-keepclassmembers class * Implements Java.io.Serializable {
Static final long serialversionuid;
private static final java.io.objectstreamfield[] Serialpersistentfields;
private void WriteObject (Java.io.ObjectOutputStream);
private void ReadObject (Java.io.ObjectInputStream);
Java.lang.Object Writereplace ();
Java.lang.Object Readresolve ();
}

-keepclasseswithmembernames class * {
Native <methods>;
}

-keepclasseswithmembers class * {
Public <init> (Android.content.Context, Android.util.AttributeSet);
}

-keepclasseswithmembers 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 class * Implements Android.os.Serializable {
*;
}

-keepclassmembers class Fqcn.of.javascript.interface.for.webview {
public *;
}

-keep class * *. r$* {
*;
}

Code obfuscation for Android common third-party packages

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.