編輯:關於Android編程
-optimizationpasses 5 # 指定代碼的壓縮級別 -dontusemixedcaseclassnames # 是否使用大小寫混合 -dontskipnonpubliclibraryclasses # 是否混淆第三方jar -dontpreverify # 混淆時是否做預校驗 -verbose # 混淆時是否記錄日志 -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* # 混淆時所采用的算法 -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 com.android.vending.licensing.ILicensingService # 保持哪些類不被混淆 -keepclasseswithmembernames class * { # 保持 native 方法不被混淆 native; } -keepclasseswithmembers class * { # 保持自定義控件類不被混淆 public (android.content.Context, android.util.AttributeSet); } -keepclasseswithmembers class * { public (android.content.Context, android.util.AttributeSet, int); # 保持自定義控件類不被混淆 } -keepclassmembers class * extends android.app.Activity { # 保持自定義控件類不被混淆 public void *(android.view.View); } -keepclassmembers enum * { # 保持枚舉 enum 類不被混淆 public static **[] values(); public static ** valueOf(java.lang.String); } -keep class * implements android.os.Parcelable { # 保持 Parcelable 不被混淆 public static final android.os.Parcelable$Creator *; } -keep class MyClass; # 保持自己定義的類不被混淆
我自己項目下的第三方混淆
-keepparameternames -renamesourcefileattribute SourceFile -keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,EnclosingMethod -optimizations !code/simplification/arithmetic -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.content.ContentProvider -keepclassmembers class * { void *(android.view.View); *** *Click(...); *** *Event(...); } -keep public class * { public protected *; } -keepclasseswithmembernames class * { native; } -keepclassmembers class * implements java.io.Serializable { static final long serialVersionUID; 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 public class * extends android.view.View { public (android.content.Context); public (android.content.Context, android.util.AttributeSet); public (android.content.Context, android.util.AttributeSet, int); public void set*(...); } -keepclasseswithmembers class * { public (android.content.Context, android.util.AttributeSet); } -keepclasseswithmembers class * { public (android.content.Context, android.util.AttributeSet, int); } -keepclassmembers class * extends android.content.Context { public void *(android.view.View); public void *(android.view.MenuItem); } -keepclassmembers class * implements android.os.Parcelable { static android.os.Parcelable$Creator CREATOR; } -keepclassmembers class **.R$* { public static ; } -keepclassmembers class * { @android.webkit.JavascriptInterface ; } -keep public interface com.android.vending.licensing.ILicensingService -dontnote com.android.vending.licensing.ILicensingService -dontpreverify -repackageclasses '' -allowaccessmodification -dontwarn android.** -keep interface android.** { *; } -keep class android.** { *; } -keep public class * extends android.** -keepclassmembers class * extends java.lang.Enum { public static **[] values(); public static ** valueOf(java.lang.String); } -keep class com.fanglin.fenhong.microbuyer.base.model.** { *;} #--------------- BEGIN: Gson防混淆 ---------- -keepattributes *Annotation* -keep class sun.misc.Unsafe { *; } -keep class com.idea.fifaalarmclock.entity.*** #-keep class com.google.gson.stream.** { *; } -keep class com.google.gson.** { *; } #--------------- END ---------- -dontwarn com.daimajia.** -keep class com.daimajia.** { *;} #--------------- BEGIN:信鴿防混淆 ---------- -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep class com.tencent.android.tpush.** {* ;} -keep class com.tencent.mid.** {* ;} #--------------- END ---------- #--------------- BEGIN: SafeWebViewBridge ---------- -keepclassmembers class cn.pedant.SafeWebViewBridge.sample.HostJsScope$RetJavaObj{ *; } -keepclassmembers class cn.pedant.SafeWebViewBridge.sample.HostJsScope{ *; } #--------------- END ---------- # -----友盟------------------- -keepclassmembers class * { public (org.json.JSONObject); } -keep public class com.fanglin.fenhong.microbuyer.R$*{ public static final int *; } #--------------- END ----------
最後在Builde.gradle中設置
buildTypes { release { // 不顯示Log buildConfigField "boolean", "LOG_DEBUG", "false" minifyEnabled true // 開啟混淆 zipAlignEnabled true // 對齊zip shrinkResources false // 刪除無用資源 debuggable false // 是否debug versionNameSuffix "_release" // 版本命名後綴 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' // 混淆文件 } debug { zipAlignEnabled false shrinkResources false minifyEnabled false versionNameSuffix "_debug" signingConfig signingConfigs.debug proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }
今天繼續講解Fragment組件的特性,主要是跟Activity的交互和生命周期的關系,我們前面已經說過Fragment是依賴於Activity的,而且生命周期也跟Act
本文實例講述了Android實現手機壁紙改變的方法。分享給大家供大家參考。具體如下:main.xml布局文件:<?xml version=1.0 encod
實現思路利用自定義的HorizontalScrollView實現。 HorizontalScrollView中管理兩個視圖,一個視圖為“菜單”,另
上一篇Android中XUtils3框架使用方法詳解(一)文章,主要介紹了XUtil3的注解模塊,網絡模塊,圖片加載模塊,今天給大家帶來數據庫模塊的講解,現在主流的ORM