Proguard with OrmLite on Android

前端 未结 8 2031
无人及你
无人及你 2020-11-27 17:46

How should I use proguard with ormlite library on Android?

Trying this:

-keep class com.j256.**
-keepclassmembers class com.j256.**
-keep enum com.j2         


        
8条回答
  •  伪装坚强ぢ
    2020-11-27 18:04

    The accepted answer was not enough for my case, so I enhanced it and this is what I ended up with:

    # OrmLite uses reflection
    -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 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 (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 ;
        @com.j256.ormlite.field.ForeignCollectionField ;
        # Add the ormlite field annotations that your model uses here
        ();
    }
    

提交回复
热议问题