Data Binding does not work

Asked

Viewed 105 times

2

I’m trying to use the Data Binding on Android.

For this I added the classpath in the application:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0-beta3'
        classpath 'com.android.databinding:dataBinder:1.0-rc4'
    }
}


apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'

But when I try to compile the following error occurs:

Error:Unable to find method 'android.databinding.tool.LayoutXmlProcessor.(Ljava/lang/String;Landroid/databinding/tool/writer/JavaFileWriter;IZLandroid/databinding/tool/LayoutXmlProcessor$OriginalFileLookup;) V'. Possible causes for this Unexpected error include:

  • Gradle’s dependency cache may be Corrupt (this sometimes occurs after a network Connection timeout. ) Re-download dependencies and Sync project (requires network)
  • The state of a Gradle build process (daemon) may be Corrupt. Stopping all Gradle daemons may Save this problem. Stop Gradle build processes (requires Restart)
  • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of Corrupt Gradle processes, you can also Try closing the IDE and then Killing all Java processes.

I don’t know if it’s really necessary to add this information, but when I try to compile just by enabling databinding:

dataBinding {
        enabled true
    }

Occurs the following :

Error:(23, 23) No Resource type specified (at 'text' with value @{user.name}').

Someone has used this feature successfully?

1 answer

1

Try to do this:

dataBinding {
    enabled = true
}

Put = after enabled

Browser other questions tagged

You are not signed in. Login or sign up in order to post.