Gradle 2.3.0-alpha1无法使用数据绑定

Kho*_*aHA 17 android build.gradle android-gradle-plugin parceler android-databinding

今天更新到Android Studo 2.3 Canary后我遇到了问题.

构建完成没有错误但是当我运行应用程序时,gradle控制台一直显示:

找不到android.databinding.annotationprocessor.ProcessDataBinding

这是我的 build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle 2.3.0-alpha1'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.android.databinding:dataBinder:1.0-rc1'
        classpath 'me.tatarka:gradle-retrolambda:3.3.1'
        classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

谢谢 !

---更新---我挣扎了几天,我发现问题来自哪里.我在我的应用程序中使用Parcels,Retrolamdas,两个库都使用'apt',这就是问题所在.

build.gradle(root)bug版本:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.android.databinding:dataBinder:1.0-rc1'
        classpath "me.tatarka:gradle-retrolambda:3.2.3"
        classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

**build.gradle(app)bug版本**

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'android-apt'

...

dependencies {
    compile 'org.parceler:parceler-api:1.1.5'
    apt 'org.parceler:parceler:1.1.5'
}
Run Code Online (Sandbox Code Playgroud)

这是固定的. build.gradle(root)修复版:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0-alpha1'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'me.tatarka:gradle-retrolambda:3.3.1'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

build.gradle(app)修复版*

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'

compile 'org.parceler:parceler-api:1.1.5'
annotationProcessor 'org.parceler:parceler:1.1.5'
Run Code Online (Sandbox Code Playgroud)

结论.我更改了retrolamdas repo版本并删除了插件:'android-apt'.如果你想查看详细信息,我会找到一些有用的链接.

https://github.com/johncarl81/parceler/issues/201 https://bitbucket.org/hvisser/android-apt/wiki/Migration

希望它有所帮助:D

yig*_*git 6

触发此问题是因为我们已将数据绑定移至annotationProcessor配置(而非提供).如果您使用的是android-apt`,它们会发生冲突,请停止使用它.我们还有另一个错误,它阻止它选择其他处理器.它已经修复,将在下一个alpha中提供.

此处的原始错误报告:https://code.google.com/p/android/issues/detail?id = 227612.如果你真的需要使用2.3,它还有一个解决方法.


Анд*_*чук -4

对我有用的临时修复: 1. 将 gradle 版本更改为: classpath 'com.android.tools.build:gradle:2.2.2'

  1. 关闭即时运行

  2. 等待 Google 的更新:)