DaoConfig init failure with greendao on Samsung Devices with Android 5.0

1.3k Views Asked by At

Crashlytics is reporting a lot of crashes in greendao:

> Caused by de.greenrobot.dao.DaoException: Could not init DAOConfig
>        at de.greenrobot.dao.internal.DaoConfig.<init>(DaoConfig.java:94)
>        at de.greenrobot.dao.AbstractDaoMaster.registerDaoClass(AbstractDaoMaster.java:44)
> ... Caused by java.lang.NoSuchFieldException: TABLENAME
>        at java.lang.Class.getField(Class.java:1104)
>        at de.greenrobot.dao.internal.DaoConfig.<init>(DaoConfig.java:56)
>        at de.greenrobot.dao.AbstractDaoMaster.registerDaoClass(AbstractDaoMaster.java:44)

Seems to be only Samsung devices (SM-G900V, SM-900A, SM-900P, SM-870A, SCH-545 etc) all running Android 5.0 Lollipop.

From my research there seems to be a Samsung class loader implementation issue on their devices that's causing this. People mentioned the possible loader as a problem in this issue: https://code.google.com/p/gmaps-api-issues/issues/detail?id=8314

People have suggested adding keep rules to Proguard but we're not using Proguard at all in the application. We do have multidexing enabled though.

Anyone have suggestions for fixes or workarounds?

2

There are 2 best solutions below

0
On

Try add this into your proguard-rules

-keepclassmembers class * extends de.greenrobot.dao.AbstractDao {
    public static java.lang.String TABLENAME;
}
-keep class **$Properties
0
On

I've encountered the same problem. I know it's the a proguard problem.

if you use the greenDao version above 3.2.0 just try the proguard-rules below

-keepclassmembers class * extends org.greenrobot.greendao.AbstractDao {
    public static java.lang.String TABLENAME;
}
-keep class **$Properties`