Android Data Binding NoSuchMethodError

后端 未结 2 759
慢半拍i
慢半拍i 2020-12-21 07:50

I\'m not able to setup my project to use Android Data Binding. This is my build.gradle:

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


buildscript          


        
相关标签:
2条回答
  • 2020-12-21 08:08

    Though George's answer is correct I think it's important to make it clear what should be in each one of the build.gradle files.

    So, in the project's build.gradle file we should have:

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.5.0'
        }
    }
    

    And in the app's build.gradle file there should be:

    apply plugin: 'com.android.application'
    // No need to add it as a plugin
    // apply plugin: 'com.android.databinding'
    
    android {
        ...
        dataBinding {
            enabled = true
        }
    
        compileSdkVersion <latest>
        buildToolsVersion <latest>
        ...
    }
    

    We don't need to add apply plugin: 'com.android.databinding' in the app's build.gradle file because, as George said:

    Android Data Binding 1.0 was released as part of the Android gradle plugin.

    Check the Data Binding Guide for more details.

    0 讨论(0)
  • 2020-12-21 08:18

    You should now set it up with 1.5.0 and without the explicit data binding import:

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.5.0'
        }
    }
    

    Android Data Binding 1.0 was released as part of the Android gradle plugin.

    0 讨论(0)
提交回复
热议问题