【发布时间】:2018-01-30 09:27:29
【问题描述】:
将支持库更新到 27.0.2 后出现此错误。
Error:Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.android.support:support-v4' has different version for the compile (21.0.3) and runtime (27.0.2) classpath. You should manually set the same version via DependencyResolution
我的项目中启用了数据绑定。
dataBinding.enabled = true
当我跑步时
gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath
这是我得到的:
+--- com.android.databinding:library:1.3.1
| +--- com.android.support:support-v4:21.0.3
| | \--- com.android.support:support-annotations:21.0.3 -> 26.0.2
| \--- com.android.databinding:baseLibrary:2.3.0-dev -> 3.0.1
+--- com.android.databinding:baseLibrary:3.0.1
+--- com.android.databinding:adapters:1.3.1
| +--- com.android.databinding:library:1.3 -> 1.3.1 (*)
| \--- com.android.databinding:baseLibrary:2.3.0-dev -> 3.0.1
+--- com.squareup.leakcanary:leakcanary-android:1.5.1
| \--- com.squareup.leakcanary:leakcanary-analyzer:1.5.1
| +--- com.squareup.haha:haha:2.0.3
| \--- com.squareup.leakcanary:leakcanary-watcher:1.5.1
+--- project :general
| +--- com.android.databinding:library:1.3.1 (*)
| +--- com.android.databinding:baseLibrary:3.0.1
| \--- com.android.databinding:adapters:1.3.1 (*)
+--- com.jakewharton:butterknife:8.8.1
| \--- com.jakewharton:butterknife-annotations:8.8.1
+--- com.github.bumptech.glide:glide:4.2.0
| +--- com.github.bumptech.glide:gifdecoder:4.2.0
| | \--- com.android.support:support-annotations:26.0.2
| +--- com.github.bumptech.glide:disklrucache:4.2.0
| \--- com.github.bumptech.glide:annotations:4.2.0
\--- com.github.apl-devs:appintro:v4.2.2
这清楚地表明 Android 数据绑定库正在使用 21.0.3 版本的支持 v4,这会导致冲突。
谁能帮忙?
【问题讨论】:
-
这个问题不是由数据绑定引起的,因为它没有使用任何依赖。只需执行 Build -> Clean Project 或 Build -> Rebuild Project。
-
@HemantParmar :不,它不起作用
-
这个答案可能对你有帮助:stackoverflow.com/questions/41568032/…
-
您使用的是 Android Studio 3.x 还是 Android Studio 2.x?我认为我们更新了数据绑定以使用 AS 3.0 的新依赖项
-
@GeorgeMount:简单地说,that has not happened。
标签: java android android-studio gradle android-databinding