0
votes

I am getting an exception:

Caused by: java.lang.ClassNotFoundException: Didn't find class "io.realm.Realm"

In build.gradle minifyEnabled true.

proguard-rules.pro:

-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.**

-keep class io.realm.{ *; }

-keepnames public class * extends io.realm.RealmObject

-keep public class * extends io.realm.RealmObject { *; }

Any idea?

1
please before implement pro-guard read the documentation - David Hackro
If this is the same as what we see on realm.io, they claim you don't need to do this: "A ProGuard configuration is provided as part of the Realm library. This means that you don’t need to add any Realm specific rules to your ProGuard configuration." That is, I suspect tweaking the proguard rules will not help solve this problem, as it is related to something else. - user1531971
Let's see your project and app build.gradle files. - user1531971
Which version of Realm are you using? Which API version device is this? - EpicPandaForce

1 Answers

0
votes

It seems that you'll have to replace this rule:

-keep class io.realm.{ *; }

With this one:

-keep class io.realm.** { *; }

Everything else that starts with io.realm can then be removed.

Why? The first rule you have here is invalid. The second one will keep everything in io.realm including any sub-packages, methods and fields. This means that it will override all of the other rules.