错误:(3,0)原因:org/apache/commons/lang3/StringUtils

Gau*_*rav 5 data-binding android gradle

我收到以下错误

错误:(3,0)原因:org/apache/commons/lang3/StringUtils

当我尝试在我的Android项目中添加数据绑定时.

我的依赖包括:

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0-alpha7'
        classpath 'me.tatarka:gradle-retrolambda:3.2.2'
        classpath 'com.android.databinding:dataBinder:1.0-rc1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

我的gradle包装器是:distributionUrl = https://services.gradle.org/distributions/gradle-2.2.1-all.zip

我的gradle文件:

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

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.quizviz.workbook.myworkbook"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dataBinding {
        enabled = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'

    compile 'io.reactivex:rxandroid:1.1.0'
    compile 'io.reactivex:rxjava:1.1.0'
    compile 'com.jakewharton.rxbinding:rxbinding:0.2.0'
    compile 'com.jakewharton:butterknife:7.0.1'



    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
    compile 'com.squareup.retrofit2:converter-jackson:2.0.0-beta3'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta3'
    compile 'com.squareup.okhttp3:okhttp:3.0.1'
    compile 'com.squareup.okhttp3:okhttp-urlconnection:3.0.1'

}
Run Code Online (Sandbox Code Playgroud)

小智 24

我花了一段时间才注意到这个问题是由谷歌更新使用数据绑定库的方式引起的.您可以在此处查看更多信息:http: //developer.android.com/tools/data-binding/guide.html.

你可以删除这两行代码:

apply plugin: 'com.android.databinding'
Run Code Online (Sandbox Code Playgroud)

而这个在buildscript的依赖项中:

classpath 'com.android.databinding:dataBinder:1.0-rc1'
Run Code Online (Sandbox Code Playgroud)

然后像这样将dataBinding部分添加到build.gradle.

buildscript {
    ...
}

android {
    ...

    dataBinding {
        enabled = true
    }
    ...

}

dependencies {
    ...
}
Run Code Online (Sandbox Code Playgroud)

干得好.这对我有用:).