【Android Studio】All com.android.support libraries must use the exact same version specification 的解決方法


在我的 app 層級build.gradle
 
...
...

dependencies {
    implementation 'com.android.support:support-v4:27.1.1'

    ...
    ...
}

出現錯誤訊息
 
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 26.1.0. Examples include com.android.support:recyclerview-v7:27.1.1 and com.android.support:customtabs:26.1.0 less... (Ctrl+F1)

There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).
 

關鍵在於
com.android.support:customtabs:26.1.0

com.android.support:support-v4:27.1.1
版本不同

所以再加入 customtabs 並指定版本為 27.1.1 即可,如下:
 
...
...

dependencies {
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'

    ...
    ...
}