Error:(3, 0) Cause: org/apache/commons/lang3/Strin

2019-06-22 01:22发布

问题:

I get the following error

Error:(3, 0) Cause: org/apache/commons/lang3/StringUtils

when I try to add data binding in my Android project.

My dependencies include :

// 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
}

My gradle wrapper is : distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip

My gradle file :

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'

}

回答1:

It took me a while to notice this problem is caused by google updating the way to use data binding library. You can see more information from here: http://developer.android.com/tools/data-binding/guide.html.

You can just remove these two lines of code:

apply plugin: 'com.android.databinding'

And this one in buildscript's dependencies:

classpath 'com.android.databinding:dataBinder:1.0-rc1'

Then add the dataBinding section to your build.gradle like this.

buildscript {
    ...
}

android {
    ...

    dataBinding {
        enabled = true
    }
    ...

}

dependencies {
    ...
}

Here you go. This works for me :).