j256 / ormlite-android

ORMLite Android functionality used in conjunction with ormlite-core
http://ormlite.com/
ISC License
1.59k stars 367 forks source link

R8 minifyEnabled proguard rules #145

Open dan-ryan opened 1 year ago

dan-ryan commented 1 year ago

I've turned on minifyEnabled in Gradle but having trouble getting it working with Ormlite.

Reading various support pages, I have this:

-keepattributes *DatabaseField*
-keepattributes *DatabaseTable*
-keepattributes *SerializedName*
-keep class com.j256.**
-keepclassmembers class com.j256.** { *; }
-keep enum com.j256.**
-keepclassmembers enum com.j256.** { *; }
-keep interface com.j256.**
-keepclassmembers interface com.j256.** { *; }
-keep @com.j256.ormlite.field.* public class *

# Keep the helper class and its constructor
-keep class * extends com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper
-keepclassmembers class * extends com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper {
  public <init>(android.content.Context);
}

# Keep the annotations
-keepattributes *Annotation*

# Keep all model classes that are used by OrmLite
# Also keep their field names and the constructor
-keep @com.j256.ormlite.table.DatabaseTable class * {
    @com.j256.ormlite.field.DatabaseField <fields>;
    @com.j256.ormlite.field.ForeignCollectionField <fields>;
    # Add the ormlite field annotations that your model uses here
    <init>();
}

-keepclassmembers class **DateTime {
    <init>(long);
    long getMillis();
}

-dontwarn com.j256.ormlite.android.**
-dontwarn com.j256.ormlite.logger.**
-dontwarn com.j256.ormlite.misc.**
-dontwarn javax.persistence.**

But I am still getting the error :

java.sql.SQLException: Could not find public constructor with ConnectionSource and optional Class parameters class UserDao.  Missing static on class?
                                                                                                        at com.j256.ormlite.dao.DaoManager.createDao(DaoManager.java:86)
                                                                                                        at com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.getDao(OrmLiteSqliteOpenHelper.java:299)

What am I missing?