我使用了snappy DB library,我的’Location’类有默认构造函数.
不使用proguard但使用proguard时工作正常:
这是我的例外:
java.lang.IllegalArgumentException: Unable to create serializer "com.d.a.c.x" for class: Object[]
这是我的代码:
import com.snappydb.DBFactory;
ArrayList<Location> mLocationsList;
snappydb = DBFactory.open(mContext, "LocationsList");
snappydb.put("LocationsList", mLocationsList.toArray());
在此行引发异常:
snappydb.put("LocationsList", locationsList.toArray());
我试过-keep class mypackagename.Location {*;在项目proguard中,我的’Location’类实现了Serilizable.
还是行不通…
解决方法:
-dontshrink标志似乎解决了这个问题.
这是SnappyDB和Kryo的完整proguard配置:
-dontshrink
-verbose
-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.**
-dontwarn sun.misc.**
-keep,allowshrinking class com.snappydb.** { *; }
-dontwarn com.snappydb.**