markdown 如何解决Gradle的“必须使用完全相同的版本规范”错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 如何解决Gradle的“必须使用完全相同的版本规范”错误相关的知识,希望对你有一定的参考价值。

# How to solve Gradle’s “must use the exact same version specification” error
[SOURCE](https://stackoverflow.com/a/42374426), [SOURCE](https://stackoverflow.com/a/42582204)

For Android Studio 3.1.1

Sometimes Gradle will throw this error when trying to build:

```
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.0.2, 26.1.0. Examples include com.android.support:animated-vector-drawable:27.0.2 and com.android.support:customtabs:26.1.0
```

Long answer short , even though you are not directly depending a dependency some of your other dependencies might. So we need to either:

- Run a dependency report to see which one is conflicted by:
	1. In Android Studio, click Terminal tab and paste this in:
	
	```
  ./gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath
  ```
  or shorter version
  
    ```
    ./gradlew app:dependencies
    ```
	2. If you encounter JDK not install error, see *How To Use The Bundled JDK in Android Studio To Run Gradle Command In Terminal* ([Gist](https://gist.github.com/vxhviet/da8563d5578f73ab96089584378df401), [Cacher](https://snippets.cacher.io/snippet/493f0b893ceccddbefe6)).

- Or add **explicitly** the library with the old version but with a new version number. In my case `com.android.support:customtabs:26.1.0` so I need to add:
`implementation "com.android.support:customtabs:27.0.2"`

以上是关于markdown 如何解决Gradle的“必须使用完全相同的版本规范”错误的主要内容,如果未能解决你的问题,请参考以下文章

markdown Agregar-的Mockito,gradle这个

markdown Gradle的buildscript块中的共享变量

markdown Lightning Fast Gradle Build

markdown [Android studio / Gradle性能提示] #android

markdown [Gradle basics] #android #android_tutorial #tutorial

markdown bug-fix-Error:这个Gradle插件需要Studio 3.0