java - android databinding - cannot find class android.view.data -


i'm trying implement databinding in android app, i'm stuck issue:

java.lang.classnotfoundexception: didn't find class "android.view.data"

my layout file looks 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 build.gradle file following lines:

databinding {     enabled = true } 

as documentation suggested: https://developer.android.com/topic/libraries/data-binding/index.html . i'm running recent version of android studio.

you need put data definition outside of linearlayout:

<layout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools">     <!-- data setup -->     <data>         <variable name="location"             type="com.myapp.models.address" />     </data>     <linearlayout         android:layout_width="match_parent"         android:layout_height="match_parent"         android:orientation="vertical"         tools:context="com.myapp.views.fragments.locationsearchfragment">     </linearlayout> </layout> 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -