Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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'

}
like image 329
Gaurav Avatar asked Feb 07 '16 07:02

Gaurav


People also ask

What is Apache Commons lang3?

The Apache Commons Lang 3 library is a popular, full-featured package of utility classes, aimed at extending the functionality of the Java API.

What is Java StringUtils?

StringUtils provides null-safe methods for handling Strings and is probably the most commonly used class in the Apache Commons project.

What is StringUtils substring?

Overview. In Java, substring() is a static method of the StringUtils class that returns the string between the given start and end index. Negative start and end index positions can be used to specify offsets relative to the end of the string.

Why do we use StringUtils?

Most common use of StringUtils is in web projects (when you want to check for blank or null strings, checking if a string is number, splitting strings with some token). StringUtils helps to get rid of those nasty NumberFormat and Null exceptions. But StringUtils can be used anywhere String is used.


Video Answer


1 Answers

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 :).

like image 132
Jessica Zeng Avatar answered Sep 16 '22 14:09

Jessica Zeng