在使用firestore时,找不到满足版本约束的“com.google.code.gson:gson”版本

x759pob2  于 2022-11-06  发布在  Go
关注(0)|答案(1)|浏览(253)

在我的Gradle中删除implementation 'com.google.firebase:firebase-firestore:21.3.0'依赖关系时不会发生此问题,并且仅在测试时导致不运行应用

以下是完整的错误消息

Cannot find a version of 'com.google.code.gson:gson' that satisfies the version constraints: 
   Dependency path 'myapp:app:unspecified' --> 'androidx.room:room-testing:2.2.1' --> 'androidx.room:room-migration:2.2.1' --> 'com.google.code.gson:gson:2.8.0'
   Constraint path 'myapp:app:unspecified' --> 'com.google.code.gson:gson:{strictly 2.7}' because of the following reason: debugRuntimeClasspath uses version 2.7
   Dependency path 'myapp:app:unspecified' --> 'com.google.firebase:firebase-firestore:21.3.0' --> 'io.grpc:grpc-android:1.21.0' --> 'io.grpc:grpc-core:1.21.0' --> 'com.google.code.gson:gson:2.7'

我该怎么办?

kupeojn6

kupeojn61#

首先,你可以像这样检查你的依赖关系树:gradlew app:dependencies(这是假设您的模块称为应用程序;对于Linux,您可能不得不这样称呼它(./gradlew app:dependencies
也就是说,您的日志似乎已经包含了您所需要的一切:room使用的是2.8.0,firebase使用的是2.7。请尝试从room(exclude group: 'com.google.code.gson')中排除gson可传递依赖项,看看是否有帮助。

相关问题