DataBinding not working after Upgrade Android Studio 2.3

后端 未结 7 1313
挽巷
挽巷 2021-02-05 10:47

DataBinding worked very well in my project, But after upgrade Android Studio 2.3 today . Run \'app\' failed because following error :

Error:(1         


        
相关标签:
7条回答
  • 2021-02-05 10:58

    android-apt and hence using apt has been deprecated since Android Studio 2.2.
    Following the android-apt migration guide, instead add the following to your build.gradle:

    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0' // use same gradle version!
        annotationProcessor 'com.android.databinding:compiler:2.3.0'
    }
    

    If you are using Kolin, instead use:

    apply plugin: 'kotlin-kapt'
    
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0' // use same gradle version!
        kapt 'com.android.databinding:compiler:2.3.0'
    }
    
    0 讨论(0)
  • 2021-02-05 11:00

    I solved this problem by changing my version of gradle to:

    classpath 'com.android.tools.build:gradle:3.0.1'
    

    Since I am using Android Studio 3.0.1

    0 讨论(0)
  • 2021-02-05 11:02

    The problem comes in a warning that is difficult to see amongst all of the errors:

    Warning:Using incompatible plugins for the annotation processing: android-apt. This may result in an unexpected behavior.

    If you remove apt, data binding works.

    0 讨论(0)
  • 2021-02-05 11:03

    I too recently downloaded the latest version of android studio 2.3.3, because I was getting the same error in version 2.2.3 i.e Error:Failed to resolve: com.android.databinding:compiler:2.2.3 ,even in the latest version, I was getting the same error,I checked the project structure, In the File>Project Structure>Project , the Android Plugin version was still 2.2.3, I changed it to 2.3.3 and the build is successful and everything is working smoothly.

    0 讨论(0)
  • 2021-02-05 11:06

    Two things Revert back your gradel-wrapper.properties distributionUrl to "https://services.gradle.org/distributions/gradle-2.14.1-all.zip" Change the gradle version classpath to previous version "'com.android.tools.build:gradle:2.2.3'"

    P.S. Instant run will stop working on ADT with older gradle version.

    0 讨论(0)
  • 2021-02-05 11:07

    Data binding also broke for us following the update to Android Studio v2.3. The GoLang Bind plugin became unable to generate library .aar files

    Our problem was resolved via a combination of GoMobile version "+eb90329 Mar 7 2017" update and GoBind plugin revert to version "0.2.6" (although the current version is "0.2.8")

    Update GoMobile:

      $ go get -u -x golang.org/x/mobile/cmd/gomobile
      $ gomobile init -x
    

    Revert GoBind plugin in build.gradle:

      plugins {
        id "org.golang.mobile.bind" version "0.2.6"
      }
    

    This solution is working on systems with go version 1.7.1 and 1.8 as well as Android Studio versions 2.1.2, 2.2.3, and 2.3.

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