相关文章推荐
憨厚的水煮肉  ·  Archive of "Oxidative ...·  2 年前    · 
阳光的骆驼  ·  pandas ...·  2 年前    · 
开朗的麻辣香锅  ·  Hive metastore ...·  3 年前    · 
文武双全的鸵鸟  ·  正义骑士号 - ...·  3 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Cannot find a version of 'com.google.code.gson:gson' that satisfies the version constraints when using firestore

Ask Question

It does not occurred when remove implementation 'com.google.firebase:firebase-firestore:21.3.0' dependency in my gradle and It causes only when to test not to run app .

here is the full error message

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'

What should I do?

First of all, you can always check your dependencies tree like this: gradlew app:dependencies (that's assuming your module in question is called app; for linux you will likely have to call it like this ./gradlew app:dependencies)

That said, your log seems to contain all you need already: room is using 2.8.0 and firebase is using 2.7. Please try to exclude gson transitive dependency, say, from room (exclude group: 'com.google.code.gson') and let's see if that helps.

you mean like this? androidTestImplementation ("androidx.room:room-testing:$rootProject.roomVersion") { exclude group: 'com.google.code.gson' } – the1900 Nov 19, 2019 at 4:10 Unbelievable! It works! How did you know? I've not even know gradle can manage explictly manage sub dependency of dependency. – the1900 Nov 19, 2019 at 14:57

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid …

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.