带包裹和领域的Proguard [英] Proguard with Parceler and Realm

查看:84
本文介绍了带包裹和领域的Proguard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Realm和Parceler,并且一切正常,但是当我启用Proguard时,执行时出现错误:

I'm using Realm and Parceler and everything is working fine but when I enable the Proguard I'm getting an error when doing:

Parcels.wrap(obj)

我遇到以下错误:

org.parceler.ParcelerRuntimeException: Unable to find generated Parcelable class for io.realm.g, verify that your class is configured properly and that the Parcelable class io.realm.g$$Parcelable is generated by Parceler.

尽管我已经将proguard规则配置为:

Although I have configured the proguard rules like:

##---------------Begin: proguard configuration for 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.*
##---------------End: proguard configuration for realm  ----------
##---------------Begin: proguard configuration for Parcel  ----------
-keep interface org.parceler.Parcel
-keep @org.parceler.Parcel class * { *; }
-keep class **$$Parcelable { *; }
-keep class org.parceler.Parceler$$Parcels
-keep @org.parceler.Parcel class * { *; }
-keep class *$$Parcelable { *; }
##---------------End: proguard configuration for Parcel  ----------

我要包裹的对象看起来像:

The object I'm trying to parcel looks like:

@Parcel(implementations = { ContentRealmProxy.class },
        value = Parcel.Serialization.BEAN,
        analyze = { Content.class })
public class Content extends RealmObject {
    ....
}

预先感谢

推荐答案

您可以添加它并查看是否有帮助:

You can add this and see if it helps:

#realm
-keepnames public class * extends io.realm.RealmObject
-keep @io.realm.annotations.RealmModule class *
-keep class io.realm.** { *; }
-dontwarn javax.**
-dontwarn io.realm.**

我认为问题在于,当您保留RealmObjects的名称时,实际上并没有保留Realm代理类的名称.

I think the issue is that while you keep the names of your RealmObjects, you don't actually keep the names of your Realm proxy classes.

所以这行

-keepnames public class * extends io.realm.RealmObject

单靠就够了.

这篇关于带包裹和领域的Proguard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆