所以我在這裏和其他地方讀了幾千條線程,它仍然不適合我。 它的錯誤就像找不到引用類sun.misc.Unsafe,或者如果我在這些上使用了dontwarn,它會編譯,但是gson部分在某個時候返回ClassCastExecption。gson obfuscation proguard錯誤
現在 - 我知道,序列化類shuold被標記爲proguard的設置-keep,我知道-keepattributes 註釋和簽名,但我仍然無法正常混淆我的代碼。
附上我的proguard的-project.txt
-optimizationpasses 2
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic
-allowaccessmodification
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-repackageclasses ''
-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*(...);
}
-keepattributes Signature
-keepattributes *Annotation*
# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class my.package.model.** { *; }
-keep class com.google.gson.** { *; }
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-keep class net.sqlcipher.** {
*;
}
-assumenosideeffects class android.util.Log {
public static *** e(...);
public static *** w(...);
public static *** wtf(...);
public static *** d(...);
public static *** v(...);
public static *** i(...);
}
編輯1 我還檢查了這個gson example proguard settings
顯然 -keepattributes Exceptions,InnerClasses,Signature,Deprecated, SourceFile,LineNumberTable,* Annotation *,EnclosingMethod sorta幫助。我沒有得到任何線索爲什麼雖然,我沒有得到日誌剪出輸出以及,它只是改變成StringBuffer笑lol –
您可以發表評論作爲自己的答案.. – giampaolo