【发布时间】:2016-05-17 00:18:03
【问题描述】:
我收到以下错误
错误:(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
}
我的 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'
}
【问题讨论】:
-
您必须将其添加到您的应用程序 gradle 文件而不是项目 gradle 中。
-
你能说得更具体些吗?我在项目 gradle 中添加了依赖项,在 app gradle 中添加了插件
-
android studio中有两个gradle文件。如果您从工作室的侧面板打开项目视图,您将看到第一个 build.gradle,当在 app 文件夹中导航时,还会有一个 build.gradle。你应该在这个 gradle 文件中添加你的依赖项
-
你不需要这个:classpath 'com.android.databinding:dataBinder:1.0-rc1'——那个版本很旧。不过,我不知道这是否是问题所在。此外,您不需要应用插件:'com.android.databinding'
-
你能发布解决方案吗?
标签: android data-binding gradle