I'm trying to implement databinding in my android app, however I'm stuck with this issue:
java.lang.ClassNotFoundException: Didn't find class "android.view.data"
My layout file looks like this:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.myapp.views.fragments.LocationSearchFragment">
<!-- data setup -->
<data>
<variable name="location"
type="com.myapp.models.Address" />
</data>
</LinearLayout>
</layout>
I updated my build.gradle
file with following lines:
dataBinding {
enabled = true
}
As the documentation suggested: https://developer.android.com/topic/libraries/data-binding/index.html . I'm running the most recent version of Android Studio.
You need to put your
data
definition outside of yourLinearLayout
:The data binding is never in the
<LinearLayout>
. You should put it in the the<layout>
zone like this: