使用Proguard构建签名构建时出错

时间:2017-03-23 05:59:53

标签: android proguard

使用ProGuard时,我收到了警告和错误消息。我已经设置了

minifyEnabled = "true" -- I don't want this to be set to false.

如何解决错误

1 个答案:

答案 0 :(得分:1)

为您正在使用的库添加Proguard规则。从错误中我认为你需要Realm和Gson的规则。这是它

# Proguard Configuration for Realm (http://realm.io)
# For detailed discussion see: https://groups.google.com/forum/#!topic/realm-java/umqKCc50JGU
# Additionally you need to keep your Realm Model classes as well
# For example:
-keep class com.yourapppackagetomodelclass.realm.** { *; }
-keep class io.realm.annotations.RealmModule
-keep @io.realm.annotations.RealmModule class *
-keep class io.realm.internal.Keep
-keep @io.realm.internal.Keep class *
-dontwarn javax.**
-dontwarn io.realm.**

##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-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 com.google.gson.examples.android.model.** { *; }

# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

##---------------End: proguard configuration for Gson  ----------

PS:代替com.yourapppackagetomodelclass.realm使用您的包RealmObject类存储

<强>更新 对于IBM警告,您可以在线检查他们的proguard规则,如果没有,则使用这样的

-keepclassmembers com.ibm.mce.sdk.adm.** { *; }
-keepclassmembers ibm.mce.sdk.plugin.inapp.** { *; }