nhachicha / SnappyDB

A key-value database for Android
1.78k stars 220 forks source link

Proguard Configuration for SnappyDB #78

Open Ranjith49 opened 8 years ago

Ranjith49 commented 8 years ago

Proguard Configuration for SnappyDB is not clear Since it includes the compile 'com.esotericsoftware.kryo:kryo:2.24.0'

It causes so many errors Can you please let us know the proguard Configuration for android

davidtcdeveloper commented 8 years ago

This works for me:

#SnappyDB
-dontwarn sun.reflect.**
-dontwarn java.beans.**
-dontwarn sun.nio.ch.**
-dontwarn sun.misc.**

-keep class com.esotericsoftware.** {*;}

-keep class java.beans.** { *; }
-keep class sun.reflect.** { *; }
-keep class sun.nio.ch.** { *; }

-keep class com.snappydb.** { *; }
-dontwarn com.snappydb.**
martinvano commented 7 years ago

I struggled with this a lot yesterday and the configuration that finally worked for me (including custom de.javakaffee:kryo serializers) is here:

In your module build.gradle you need to strip out duplicate dependencies:

   compile('com.snappydb:snappydb-lib:0.5.2') {
        exclude module: 'kryo'
    }

    compile('com.esotericsoftware.kryo:kryo:2.24.0') {
//        exclude module: 'minlog'
    }

    compile('de.javakaffee:kryo-serializers:0.41') {
        exclude module: 'minlog'
        exclude module: 'kryo'
    }

In your proguard-rules.pro append this (inspired a bit by @davidtcdeveloper ):

#SnappyDB
-dontwarn sun.reflect.**
-dontwarn java.beans.**
-dontwarn sun.nio.ch.**
-dontwarn sun.misc.**

-keep class com.esotericsoftware.** {*;}

-keep class java.beans.** { *; }
-keep class sun.reflect.** { *; }
-keep class sun.nio.ch.** { *; }

-keep class com.snappydb.** { *; }
-dontwarn com.snappydb.**
#kryo
-dontwarn sun.reflect.**
-dontwarn java.beans.**
-keep,allowshrinking class com.esotericsoftware.** {
   <fields>;
   <methods>;
}
-keep,allowshrinking class java.beans.** { *; }
-keep,allowshrinking class sun.reflect.** { *; }
-keep,allowshrinking class com.esotericsoftware.kryo.** { *; }
-keep,allowshrinking class com.esotericsoftware.kryo.io.** { *; }
-keep,allowshrinking class sun.nio.ch.** { *; }
-dontwarn sun.nio.ch.**
-keep public class * extends com.google.protobuf.GeneratedMessage { *; }
-keep class de.javakaffee.kryoserializers.** { *; }
-dontwarn de.javakaffee.kryoserializers.**
-keep class com.esotericsoftware.kryo.serializers.** { *; }
-dontwarn com.esotericsoftware.kryo.serializers.**

Edit: Now I see it contains some duplicates, but it works and you get the point.