天天看點

Android API28:All com.android.support libraries must use the exact same version specification

最近将sdk版本下載下傳至最新的API 28,将compileSdkVersion改為28後,并将官方支援庫改為相應版本時:

def support_version = "28.0.0-alpha3"
implementation "com.android.support:appcompat-v7:$support_version"      

提示有錯誤,錯誤詳情為:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0-alpha3, 27.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0-alpha3 and com.android.support:recyclerview-v7:27.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).

我的解決方法是将所提示缺少的部分(animated-vector-drawable和recyclerview-v7)添加進去并使用相同的版本号,添加後的代碼如下:

def support_version = "28.0.0-alpha3"
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:support-v4:$support_version"
implementation "com.android.support:recyclerview-v7:$support_version"      

繼續閱讀