Android毕加索给出混合版本错误

Android Picasso gives mixing versions error

由于混合版本,我收到错误消息

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0-rc01, 27.1.0. Examples include 'com.android.support:animated-vector-drawable:28.0.0-rc01' and 'com.android.support:exifinterface:27.1.0'

com.android.support:exifinterface:27.1.0 在毕加索手下, 也许是 Picasso,因为我添加了 28 版,但 Picasso 仍在使用 27 版,而 Volley 正在使用 28 版:

+--- com.android.volley:volley:1.1.+ -> 1.1.1
+--- com.android.support:exifinterface:28.0.0
|    \--- com.android.support:support-annotations:28.0.0
+--- com.android.support:support-annotations:28.0.0
\--- com.squareup.picasso:picasso:2.71828
 +--- com.squareup.okhttp3:okhttp:3.10.0
 |    \--- com.squareup.okio:okio:1.14.0
 +--- com.android.support:support-annotations:27.1.0 -> 28.0.0
 \--- com.android.support:exifinterface:27.1.0 -> 28.0.0 (*)


dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:28.0.0-rc01'
implementation 'com.android.volley:volley:1.1.+'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
}

如何解决这个问题,我应该将 SDK 降级到 27 吗?还是使用 Glide?

谢谢,

最简单的解决方法是为存在此问题的库添加匹配版本(就像我说的)。

但是现在,改变依赖关系如下:

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.support:support-annotations:28.0.0' // Like this

或者您也可以尝试将 com.android.support:support-annotations 覆盖为 v 28.0.0

如果这没有帮助,因为我已经检查过 picasso is updated to 28.0.0 支持库,那么它使用的库可能仍在使用 27.1.0

所以你可以降级到27.1.0,或者使用Glide

我不想评判这些库,但对于新版本,我更喜欢 Glide,它甚至对 Kotlin 都有更好的文档,并为新 API 使用快照。因此,将此作为最后的选择,或者,只需添加最新版本并使用它即可。

试一试:

implementation ('com.squareup.picasso:picasso:2.71828') {
        exclude group: 'com.android.support'
        exclude module: ['exifinterface', 'support-annotations']
}