javaandroidandroid-roomandroid-proguard

How to set proguard rule for Room library on Android


In my application i want use Room library for use database, and for finally for generate APK i enable minify option (proguard) in Build.Gradle .

I use below version of Room library :

implementation "android.arch.persistence.room:runtime:1.1.1"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"

I write below codes in proguard-rules :

-dontwarn class android.arch.persistence.room.paging.LimitOffsetDataSource
-dontwarn interface android.arch.persistence.room.paging.LimitOffsetDataSource
-dontwarn class android.arch.util.paging.CountedDataSource
-dontwarn interface android.arch.util.paging.CountedDataSource

But when generate APK show me below error in Build tab :

Unknown option 'android.arch.persistence.room.paging.LimitOffsetDataSource' in line 39 of file '/Volumes/M/Test Projects/MyApp/app/proguard-rules.pro'

Show me error for this line :

-dontwarn class android.arch.persistence.room.paging.LimitOffsetDataSource

How can fix this issue?


Solution

  • Add below lines for keep section in your proguard file.

    -dontwarn android.arch.util.paging.CountedDataSource
    -dontwarn android.arch.persistence.room.paging.LimitOffsetDataSource