此问题可能是由于使用了过时的版本或库的冲突导致的。您可以尝试使用最新版本的库来解决此问题,或者在依赖项中使用同一版本的库。以下是可能的
更新依赖项中的库版本,以使用最新版本。
尝试使用同一版本的库。例如:
dependencies { def appcompat_version = '1.3.0' implementation "androidx.appcompat:appcompat:$appcompat_version" implementation "com.google.android.material:material:$appcompat_version" implementation "androidx.lifecycle:lifecycle-livedata-ktx:$appcompat_version" }
将全部的依赖项升级到最新的版本。
在依赖项中排除可能导致冲突的库。例如:
dependencies { implementation ("androidx.appcompat:appcompat:1.3.0") { exclude group: 'com.google.android.material' } implementation "com.google.android.material:material:1.3.0" implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.0" }
这里有一个示例项目,显示如何解决此问题:https://github.com/jraska/livedata-testing-sample-app/commit/9be6f211af2f5cf9b399ea4fa9198b0e49b2a3dc