I'm trying to add ViewModel and LiveData to a Kotlin app. I have the following dependencies added to my module's build.gradle:

implementation "android.arch.lifecycle:extensions:1.1.1"
kapt "android.arch.lifecycle:compiler:1.1.1"
testImplementation "android.arch.core:core-testing:1.1.1"

我收到以下错误:

Android dependency 'android.arch.lifecycle:runtime' has different version for the compile (1.0.0) and runtime (1.1.1) classpath. You should manually set the same version via DependencyResolution

Removing the first line (extensions) fixes the issue, indicating that the error is coming from there, but I can't figure out why.

推荐答案

Apparently support-v4 was causing the conflict. In the case of this question, the Gradle dependency task wasn't working correctly, but for anyone else who runs into this issue:

./gradlew :app:dependencies will show the sub-dependencies used by your dependencies. Search the output of this command (changing app for your module name) for the dependency causing the conflict.

Kotlin相关问答推荐

如何访问方法引用的接收者?

Kotlin中函数引用的否定

使用另一个对象的列表创建对象

在 Kotlin 中将 Array 转换为 IntArray 时丢失值

Kotlin中是否可以混合使用推断和显式的通用类型参数?

如何获取@JsonProperty 名称列表?

kotlin 如何决定 lambda 中的参数名称?

如何将字符串格式化为电话号码kotlin算法

如何在kotlin中使用协程每秒调用一个函数

来自类型参数的属性的自定义 getter

如何从 Java 中隐藏 Kotlin 的 lateinit var 支持字段?

Android Studio 将 Java 转换为 Kotlin 错误无法推断此参数的类型

使用范围的稀疏sparse值列表

指定为非null的参数在ArrayAdaper中为null

这是 Kotlin 中的错误还是我遗漏了什么?

如何启用spring security kotlin DSL?

IllegalStateException:function = , count = 3, index = 3

Kotlin:测试中的 java.lang.NoSuchMethodError

如何在 Kotlin 中按字母顺序对字符串进行排序

Kotlin反射不可用