Search code examples
androideclipseandroid-gradle-pluginadtandroid-databinding

Android Data binding in Eclipse ADT project (without gradle)


I am trying to implement android data binding library in Eclipse(Juno) ADT project that does not have gradle. When I try to add data tag under layout, I get below error "Attribute is missing the namespace prefix" at variable line

    <layout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools">
   <data>
       <variable name="user" type="com.example.User"/>
   </data>
<LinearLayout 
    android:background="#ffffff"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="@dimen/activity_horizontal_margin"
    tools:context="com.example.exam"
    android:orientation="vertical"
    android:focusable="true" 
    android:focusableInTouchMode="true"
    >
   <TextView 
        android:id="@+id/label_name"
        android:layout_marginTop="20dp"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="CLASS NAME"
        android:textColor="@color/colorBlue"
        android:textSize="13sp"
        />
    </LinearLayout>
</layout>

I think the issue is due to I am not using gradle to build my project hence i do not have equivalent of below in ADT non-gradle project

android {
    ....
    dataBinding {
        enabled = true
    }
}

Can anyone please help on how can I use data binding for non-gradle ADT eclipse project?


Solution

  • The gradle build does generate compile-time classes that does the bind for you, so if you are not using gradle and Google doesn't offer another solution you will need to move to another solution.