Proguard config for Realm

1,620 views
Skip to first unread message

Srđan Tot

unread,
Nov 7, 2014, 5:53:48 AM11/7/14
to realm...@googlegroups.com
I was wondering if there are any guidelines for setting up proguard?

All I can find is this post which suggest adding -keep class io.realm.** { *; } but that will just keep every classes and members in Realm. It would be nice if we could get proguard config that will keep only needed classes and members.

Brian Munkholm

unread,
Nov 7, 2014, 10:42:39 AM11/7/14
to realm...@googlegroups.com
Sure, it might be possible to optimise that a bit. We will have a look at it.

skunkwerk

unread,
Nov 25, 2014, 11:49:22 PM11/25/14
to realm...@googlegroups.com
I tried that in my proguard-rules file, but it's throwing errors complaining about missing classes during compilation now, like:

Warning:io.realm.processor.RealmValidationListGenerator: can't find referenced class javax.tools.JavaFileObject
Warning:io.realm.processor.RealmVersionChecker: can't find referenced class javax.annotation.processing.ProcessingEnvironment

Here is my full proguard file: http://pastebin.com/VvMGRF4F

Any suggestions?

thanks,
imran

Christian Melchior

unread,
Nov 27, 2014, 3:23:03 PM11/27/14
to Skunkwerk, realm...@googlegroups.com
Hi

This setup should:

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

It is not perfect though, and we are still looking at ways to improve compatibility with ProGuard, but I will keep you posted once we know more.


--
Christian Melchior
Senior Android Developer


--
You received this message because you are subscribed to the Google Groups "Realm Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realm-java+...@googlegroups.com.
To post to this group, send email to realm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/realm-java/b69f409b-c3a3-4ff8-906e-a6fd2771614f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



{#HS:57089923-61#}

Igor Tseglevskiy

unread,
Nov 28, 2014, 9:13:55 AM11/28/14
to realm...@googlegroups.com, skun...@gmail.com, he...@realm.io
It doesn't work for me yet:

D/dalvikvm(32009): No JNI_OnLoad found in /data/app-lib/com.yandex.sample.metrica-1/libYandexMetricaNativeModule.so 0x42199b40, skipping init
E/AndroidRuntime(31969): FATAL EXCEPTION: main
E/AndroidRuntime(31969): java.lang.IllegalStateException: Objects cannot be changed outside a transaction; see beginTransaction() for details.
E/AndroidRuntime(31969): at io.realm.internal.Group.throwImmutable(Unknown Source)
E/AndroidRuntime(31969): at io.realm.internal.Group.getTable(Unknown Source)
E/AndroidRuntime(31969): at io.realm.Realm.getTable(Unknown Source)
E/AndroidRuntime(31969): at io.realm.RealmQuery.getTable(Unknown Source)
E/AndroidRuntime(31969): at io.realm.RealmQuery.<init>(Unknown Source)
E/AndroidRuntime(31969): at io.realm.Realm.where(Unknown Source)
E/AndroidRuntime(31969): at ru.lizaalert.a.a.b.a.a.onActivityCreated(Unknown Source)

But -dontobfuscate fixes this. Any ideas?

Tim Specht

unread,
Dec 12, 2014, 8:25:24 AM12/12/14
to realm...@googlegroups.com, skun...@gmail.com, he...@realm.io
I currently have the following proguard config:

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

The app immediately crashes when I start it, adding -dontobfuscate fixes it but isn't a real solution for me... Any way to fix this or am I missing out on something?

Christian Melchior

unread,
Dec 12, 2014, 9:41:05 AM12/12/14
to Tim Specht, skun...@gmail.com, realm...@googlegroups.com
Hi Tim

I have just tested that proguard config on the introExample using Android Studio 1.0 with build tools 21.1.1 where the app works as expected. Can you get it to work there as well?
If yes, can you post a logcat output from your app? That way we might be able to see what is going wrong?


--
Christian Melchior
Senior Android Developer


On Fri, Dec 12, 2014 at 1:25 PM UTC, Tim Specht <t...@dubsmash.com> wrote:
I currently have the following proguard config:

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

The app immediately crashes when I start it, adding -dontobfuscate fixes it
but isn't a real solution for me... Any way to fix this or am I missing out
on something?



On Fri, Dec 12, 2014 at 1:25 PM UTC, Tim Specht <t...@dubsmash.com> wrote:
I currently have the following proguard config:


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

The app immediately crashes when I start it, adding -dontobfuscate fixes it but isn't a real solution for me... Any way to fix this or am I missing out on something?



On Fri, Nov 28, 2014 at 2:14 PM UTC, Igor Tseglevskiy <igor.tse...@gmail.com> wrote:
It doesn't work for me yet:


D/dalvikvm(32009): No JNI_OnLoad found in /data/app-lib/com.yandex.sample.metrica-1/libYandexMetricaNativeModule.so 0x42199b40, skipping initE/AndroidRuntime(31969): FATAL EXCEPTION: main
{#HS:57089923-61#}

Savelii Zagurskii

unread,
Dec 16, 2014, 6:36:00 PM12/16/14
to realm...@googlegroups.com, skun...@gmail.com, he...@realm.io
Hi, Tim!
I managed to fix this by adding my defined Realm classes to ProGuard.

Example:
-keep class com.my.example.RealmUser { *; }

And of course I added these lines too:
-keep class io.realm.** { *; }
-dontwarn javax.**
-dontwarn io.realm.**

пятница, 12 декабря 2014 г., 16:25:24 UTC+3 пользователь Tim Specht написал:
Reply all
Reply to author
Forward
0 new messages