drakeet / MultiType

Flexible multiple types for Android RecyclerView.
Apache License 2.0
5.76k stars 751 forks source link

Proguard for registered class #301

Closed huynguyennovem closed 4 years ago

huynguyennovem commented 4 years ago

What kind of issue is this?

Info:
Description:

The problem came when set minifyEnabled true and shrinkResources true for buildTypes in app gradle. The data can not parse and display as null.

Reproduction Steps:
  1. Set in app gradle:
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
  2. Set in proguard-rules.pro for keeping Gson parse entity class
    -keep class com.example.entity.response.** { *; }
  3. Build release apk and the result is empty data when display
My thoughts:

After trying, I saw that I have not kept adapter class which uses in multi type adapter.

What did I do:

Modify proguard-rules.pro:

-keep class com.example.entity.response.** { *; }
-keep class com.example.entity.adapter.** { *; }

Then, it worked!

drakeet commented 4 years ago

This is not a problem or scope of MultiType.