There are many answers here for individual solutions that do not really get down to the problem. Here is how to solve this in general:
As the original log output suggests, it is useful to run the build in the terminal with the following command:
./gradlew --info assembleDebug
This will give you a list of all dependencies that are involved in the conflict. It looks similar to this (I removed the package name stuff to make it a bit more readable):
Dependency Resolution Help: Displaying all currently known paths to any version of the dependency: Artifact(groupId=com.google.firebase, artifactId=firebase-iid)
-- task/module dep -> [email protected]
---- firebase-analytics:17.2.0 library depends -> [email protected]
------ play-services-measurement-api:17.2.0 library depends -> [email protected]
-- task/module dep -> [email protected]
---- firebase-core:17.2.0 library depends -> [email protected]
------ firebase-analytics:17.2.0 library depends -> [email protected]
-------- play-services-measurement-api:17.2.0 library depends -> [email protected]
-- task/module dep -> [email protected]
---- play-services-measurement-api:17.2.0 library depends -> [email protected]
-- task/module dep -> [email protected]
-- task/module dep -> [email protected]
---- firebase-messaging:17.1.0 library depends -> firebase-iid@[16.2.0]
-- task/module dep -> com.pressenger:[email protected]
---- com.pressenger:sdk:4.8.0 library depends -> [email protected]
------ firebase-messaging:17.1.0 library depends -> firebase-iid@[16.2.0]
From this list you get to know 2 things:
- Where is the conflicting depedency found
- What versions of the conflicting dependency are set up
In my case the conflicting dependency is firebase-iid
: It's either @19.0.0
or @16.2.0
To fix this you must define the top-level dependency of the wrong firebase-iid
explicitly in your build.gralde
.
So in the upper log you can see that there are 2 examples of an out-dated version of [email protected]. One comes from -- task/module dep -> [email protected]
the other one from a third-party library (pressenger). We don't have influence on the third-party library, so nothing to do here.
But for the other dependency, we have to declare it explicitly with the correct version:
implementation 'com.google.firebase:firebase-messaging:20.0.0'
Now the build works again. Happy ending :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…