Compile time error occurs when I try to run with ProGuard and data binding enabled.
Note : Same code works when proGuard is disabled.
Here is the console error message
Cannot find the setter for attribute
'bind:itemOrders'
with parameter typejava.util.List<com.example.boss.ItemOrder>
onandroid.support.v7.widget.RecyclerView
.
Here is my layout where I bind recycler view using bind attribute.
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bind="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View" />
<variable
name="viewModel"
type="com.example.boss.BossViewModel" />
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/itemOrderRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/ItemOrders"
bind:itemOrders="@{viewModel.itemOrders}"/>
</RelativeLayout>
</layout>
Here is my custom data binding method
@BindingAdapter("bind:itemOrders")
public static void bindList(RecyclerView view, List<ItemOrder> itemOrders) {
view.setLayoutManager(new LinearLayoutManager(view.getContext()));
view.setAdapter(new ItemOrderAdapter(itemOrders));
}
Here is my proguard-rules.pro file
-keepclassmembers public class com.example.boss.BossViewModel{*;}
-keep class android.databinding.** { *; }
-keepattributes *Annotation*
-keepattributes javax.xml.bind.annotation.*
-keepattributes javax.annotation.processing.*
-keepclassmembers class ** {
@android.databinding.BindingAdapter public *;
}
-dontwarn android.databinding.**