Android Gradle Dependence problem record

Cannot find a version of ‘group:module:version’ that satisfies the version constraints:

1. Scenario 1: The version of conpileOnly library [A] in the project is higher than the version of [A] that is actually relied on in A tripartite library.

For example,

Cannot find a version of 'com.google.android.material:material' that satisfies the version constraints:
           Dependency path 'com. Huami. Flutter. Feedback: flutter_feedback: 1.0 the SNAPSHOT' --> 'com. Google. Android. Material: material: 1.4.0'
           Constraint path 'com. Huami. Flutter. Feedback: flutter_feedback: 1.0 the SNAPSHOT' --> 'com. Google. Android. Material: material: {strictly 1.0.0}' because of the following reason: releaseRuntimeClasspath uses version 1.0. 0
Copy the code

The Feedback plugin module compileOnly contains the 1.4.0 material library. However, version 1.0.0 is used in the introduced tripartite library. This is what happens.

Possible cause (not necessarily correct based on your own analysis) : The version of compileOnly is actually the one that takes effect at compile time. If it is higher than the actual dependent version. If compiled, there may be apis or resources in the code that are not defined or implemented in the lower version library. Cause run-time crash problems. This is not allowed to happen at compile time. So an error is reported before compilation.

Solution: Use implementation to rely on higher versions of the library. Because you are using a higher version, it should be needed in actual coding. Take the code snippet above. If you use a lower version of the Material library, resource links cannot be found. Because the shapeAppearance attribute is used in the project.

2. Case 2: Two libraries are directly or indirectly dependent. Group and moudle names are the same, but version is an abnormal version name.

Library, for example, A:com.com pany. Base. Util: 1.0.0. B:com.com pany projectA library. Base. Util: 1.0.0. ProjectB

Possible cause: We know that Gradle will select a higher version of the library to replace the lower version of the library. In this case, gradle does not know how to compare two versions, so it is impossible to determine which version to rely on.

Solution: Figure out which version is actually being used in your project. Use this version explicitly. If different versions are introduced in the tripartite library, you can exclude them by using exclude.