Android Code Obfuscation example

Source: Internet
Author: User

Refer to other information to confuse the project code

Third-party libraries such as Slidingmenu Actionbarsherlock Fastjson volley httpclient were used in the project,

And the use of WebView + JS, and Weibo sharing features.

# Specify the compression level of the Code-optimizationpasses 5-dontusemixedcaseclassnames #                                               Whether to confuse third party jar-dontskipnonpubliclibraryclasses -dontpreverify-keepattributes Sourcefi                                                                        Le,linenumbertable-verbose -optimizations!code/simplification/arithmetic,!field/*,!class/merging/*-libraryjars Libs/httpmim E-4.1.3.jar-libraryjars Libs/libammsdk.jar-libraryjars Libs/fastjson-1.1.34.android.jar-libraryjars libs/ Commons-lang.jar-libraryjars libs/weibosdkcore.jar# WebView + js# Keep classes WebView class with-keepclassmembers com.goldnet.mobile.activity.InfoDetailActivity {public *;} # Keep all internal classes that use the WebView class-keepclassmembers class com.goldnet.mobile.activity.infodetailactivity$*{*;} # What classes to keepNot to be confused-keep class android.** {*;} -keep public class * extends Android.view-keep public class * extends Android.app.Activity- Keep public class * extends Android.app.application-keep public class * extends Android.app.Se Rvice-keep public class * extends Android.content.pm-keep public class * extends Android. Content. Broadcastreceiver-keep public class * extends Android.content.contentprovider-keep Publi C Class * extends Android.app.backup.backupagenthelper-keep public class * extends Android.preference.Prefer Ence-keep public class Com.android.vending.licensing.ILicensingService #ACRA specifics# we Need line numbers in our stack traces otherwise they is pretty useless-renamesourcefileattribute sourcefile-keepattribute s sourcefile,linenumbertable# ACRA needs "annotations" so add this ...-keepattributes *annotation*# keep NATIve method is not confused-keepclasseswithmembernames class * {native  <Methods>;} # Keep custom control classes from being confused-keepclasseswithmembers class * { public<Init>(Android.content.Context, android.util.AttributeSet);} -keepclasseswithmembers class * { public<Init>(Android.content.Context, android.util.AttributeSet, int); }-keepclasseswithmembers class * {void onclick* (...);} -keepclasseswithmembers class * {* * * *callback (...);} # Keep setters in views so it animations can still work.# see Http://proguard.sourceforge.net/manual/examples.html#beans   -keepclassmembers public class * extends Android.view.View {void set* (* * *); Get* ();} # Keep the custom control class from being confused-keepclassmembers class * extends android.app.Activity {public void * (Android.view . View);} # keep Enum enum class not to be confused-keepclassmembers enum * {public static **[] Val    UEs (); public static * * VALUEOF (java.lang.String);} # Keep Parcelable not be confused-keep class * implements android.os.Parcelable {public static final and Roid.os.parcelable$creator *;} -keepclassmembers class * *. r$* {public static< Fields>;} # HTTP Client-keep class org.apache.http.** {*;} #-keep class Com.tencent.mm.sdk.openapi.WXMediaMessage {*;} -keep class com.tencent.mm.sdk.openapi.** implements Com.tencent.mm.sdk.openapi.wxmediamessage$imediaobject {*;} # Fastjson-keep class com.alibaba.fastjson.**{*;}   # Keep all Javabean-keep class com.goldnet.mobile.entity.**{*;}  # keep Generic-keepattributes Signature #-keep public class * Implements java.io.Serializable {# public *;  #} #-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 (); #}-keep class org.apache.commons.lang.**{*;} # Sina Weibo-keep class com.sina.**{*;} ######## other third-party libraries #######-dontwarn Org.bouncycastle.**-keep class org.bouncycastle.**{*;} -donTwarn Android-async-http-1.4.4.jar.**-keep class android-async-http-1.4.4.jar.**{*;} -dontwarn Decoder.**-keep class decoder.**{*;} # Volley-dontwarn Com.android.volley.jar.**-keep class com.android.volley.**{*;} # Actionbarsherlock-dontwarn Com.actionbarsherlock.**-keep class com.actionbarsherlock.**{*;} # Slidingmenu-dontwarn Com.jeremyfeinstein.slidingmenu.lib.**-keep class com.jeremyfeinstein.slidingmenu.lib.**{*;} -dontwarn Com.cairh.app.sjkh.**-keep class com.cairh.app.sjkh.**{*;}

 

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.