Android Error

java.lang.IllegalStateException: Required DataBindingComponent is null in class ItemMovieBindingImpl. A BindingAdapter in hbs.com.boostcampmoviesearch.MovieVM is not static and requires an object to use, retrieved from the DataBindingComponent. If you d..



1. Error Content : 


java.lang.IllegalStateException: Required DataBindingComponent is null in class ItemMovieBindingImpl. A BindingAdapter in hbs.com.boostcampmoviesearch.MovieVM is not static and requires an object to use, retrieved from the DataBindingComponent. If you don't use an inflation method taking a DataBindingComponent, use DataBindingUtil.setDefaultComponent or make all BindingAdapter methods static.


2. Error reason:


1
2
3
4
5
6
7
8
9
10
11
val globalParam = ???
 
 
 
BindingAdapter(["param1"])
 
fun abcde(param1){
 
globalParam
 
}
cs


BindingAdapter는 독립적이여야 한다. 파라매터들은 xml을 통해서만 값을 받아야한다.

그렇지 않고 globalParam을 이용했기 때문에 오류가 일어나는 것이다.


3. Error Solve


1
2
3
4
5
6
7
8
9
BindingAdapter(["param1","param2"])
 
fun abcde(param1, param2){
 
param1
 
param2
 
}
cs


1
2
3
4
5
6
7
<ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:scaleType="fitXY"
            bind:param1="@{param1}"
            bind:param2="@{param2}"/>
cs

xml을 통해서 모든 변수들을 제어해준다면 해당 오류는 없어진다.