Java – Array serialization exceptions using proguard android

Array serialization exceptions using proguard android… here is a solution to the problem.

Array serialization exceptions using proguard android

I used snappy DB library My “location” class has a default constructor.
The obfuscator is not used but works fine when the obfuscator is used:

This is my exception:

java.lang.IllegalArgumentException: Unable to create serializer "com.d.a.c.x" for class: Object[]

Here is my code :

import com.snappydb.DBFactory;
ArrayList<Location> mLocationsList;
snappydb = DBFactory.open(mContext, "LocationsList");
snappydb.put("LocationsList", mLocationsList.toArray());

Throw an exception on this line:

snappydb.put("LocationsList", locationsList.toArray());

I tried -keep class mypackagename. Location { *; In the project proguard, my “Location” class implements Serilizable.

Still can’t….

Solution

The -dontshrink flag seems to solve the problem.

Here is the full obfuscator configuration for SnappyDB and Kryo:

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

Related Problems and Solutions