标签:
Proguard
的配置,啥都不说了,全都是泪。
搞android的兄弟,将代码用Proguard混淆后,app出现闪退。整了一下午,后台的捉急了,也参加进来整了。
说下项目架子
多余的不说,直接上最后能用的progurd配置
-dontpreverify
-repackageclasses ‘‘
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-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.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-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.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-dontwarn rx.**
-dontwarn okio.**
-dontwarn com.squareup.okhttp.**
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn retrofit.**
-dontwarn retrofit.appengine.UrlFetchClient
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {
@retrofit.http.* <methods>;
}
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
#关键的地方,一定要将model层包 使用 keep class
-keep class com.<model>.** { *; }
#删除日志
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
}
build.gradle
也需要添加额外的依赖
#版本不要换,必须1.4,1.4之上的版本不行
compile ‘org.joda:joda-convert:1.4‘
还有一个问题就是android
代码充斥着大量的System.out.println
o(╯□╰)o。
后用正则 空格 替换掉 system\.out\.print.*\)\;
标签:
原文地址:http://my.oschina.net/myprogworld/blog/402646