在我们的项目中尝试包括以下依赖项时,我们会收到此错误:
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-fragment</artifactId>
<version>28.0.0</version>
<type>aar</type>
</dependency>
我们已粘贴完整的跟踪here。据我们所知,同一程序集取决于两个不同的版本。怎么可能?
and
+-com.google.zxing:android:4.7.10
+-com.android.support:support-fragment:28.0.0
+-com.android.support:support-compat:28.0.0
+-com.android.support:collections:28.0.0
+-com.android.support:support-annotations:28.0.0
and
+-com.google.zxing:android:4.7.10
+-com.android.support:support-fragment:28.0.0
+-com.android.support:support-compat:28.0.0
+-android.arch.lifecycle:runtime:1.1.1
+-android.arch.lifecycle:common:1.1.1
+-com.android.support:support-annotations:26.1.0
我们如何解决此错误?
答案 0 :(得分:0)
尝试将此代码放在Gradle文件的底部,其中有依赖项列表
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support' && !requested.name.contains('multidex')) {
details.useVersion '28.0.0'
}
}
}
答案 1 :(得分:0)
您始终可以通过将库添加到依赖项中来覆盖库的旧版本。对于您的问题,请尝试通过添加support-annotations
依赖项来覆盖,例如:
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-annotations</artifactId>
<version>28.0.0</version>
<type>aar</type>
</dependency>