更新:查看潜在的重复链接',从那里得不到完整的答案。
感谢您指向Using gradle to find dependency tree。但无法从那里得到答案,
这个解决版本的应用程序(25.4.0)来自(为什么不说已解决(25.0.1)),在某处可以指定版本为'已从' )?
是检查依赖图以了解lib / sdk使用的唯一方法吗?即使您发现了这个问题,但如果您必须使用您选择的版本,该怎么办?
正如您所提到的,如果您强制使用较新版本,则可能导致lib / sdk无法正常运行。
最佳/推荐方法是什么?
更新二:
尝试使用链接中建议的解决方案:,它仍然无效。
但是使用
configurations.all {
exclude group:"com.android.support", module: "support-v4"
exclude group:"com.android.support", module: "support-annotations"
exclude group:"com.android.support", module: "support-compat"
exclude group:"com.android.support", module: "support-core-utils"
exclude group:"com.android.support", module: "support-core-utils"
}
将编译没有错误,但应用程序无法启动(在lib内部崩溃)。
图表显示:
Information:Gradle tasks [androidDependencies]
Error:\--- com.android.support:support-annotations:25.4.0@jar
Error:+--- com.android.support:support-annotations:25.4.0@jar
Error:\--- com.android.support:support-compat:25.4.0@aar
Error:\--- com.android.support:support-annotations:25.4.0@jar
Error:+--- com.android.support:support-annotations:25.4.0@jar
Error:\--- com.android.support:support-compat:25.4.0@aar
Error:\--- com.android.support:support-annotations:25.4.0@jar
Error:+--- com.android.support:support-annotations:25.4.0@jar
Error:\--- com.android.support:support-compat:25.4.0@aar
Error:\--- com.android.support:support-annotations:25.4.0@jar
Error:\--- com.android.support:support-annotations:25.4.0@jar
Error:+--- com.android.support:support-annotations:25.4.0@jar
Error:\--- com.android.support:support-compat:25.4.0@aar
Error:\--- com.android.support:support-annotations:25.4.0@jar
Error:+--- com.android.support:support-annotations:25.4.0@jar
Error:\--- com.android.support:support-compat:25.4.0@aar
Error:\--- com.android.support:support-annotations:25.4.0@jar
Error:+--- com.google.android.gms:play-services-identity:9.2.1@aar
Error:| +--- com.google.android.gms:play-services-base:9.2.1@aar
Error:| | +--- com.google.android.gms:play-services-basement:9.2.1@aar
Error:| | | \--- com.android.support:support-v4:25.4.0@aar
Error:| | | +--- com.android.support:support-compat:25.4.0@aar
Error:| | | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | | +--- com.android.support:support-media-compat:25.4.0@aar
Error:| | | | +--- com.android.support:support-annotations:25.4.0@jar
Error:| | | | \--- com.android.support:support-compat:25.4.0@aar
Error:| | | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | | +--- com.android.support:support-core-utils:25.4.0@aar
Error:| | | | +--- com.android.support:support-annotations:25.4.0@jar
Error:| | | | \--- com.android.support:support-compat:25.4.0@aar
Error:| | | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | | +--- com.android.support:support-core-ui:25.4.0@aar
Error:| | | | +--- com.android.support:support-annotations:25.4.0@jar
Error:| | | | \--- com.android.support:support-compat:25.4.0@aar
Error:| | | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | | \--- com.android.support:support-fragment:25.4.0@aar
Error:| | | +--- com.android.support:support-compat:25.4.0@aar
Error:| | | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | | +--- com.android.support:support-media-compat:25.4.0@aar
Error:| | | | +--- com.android.support:support-annotations:25.4.0@jar
Error:| | | | \--- com.android.support:support-compat:25.4.0@aar
Error:| | | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | | +--- com.android.support:support-core-ui:25.4.0@aar
Error:| | | | +--- com.android.support:support-annotations:25.4.0@jar
Error:| | | | \--- com.android.support:support-compat:25.4.0@aar
Error:| | | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | | \--- com.android.support:support-core-utils:25.4.0@aar
Error:| | | +--- com.android.support:support-annotations:25.4.0@jar
Error:| | | \--- com.android.support:support-compat:25.4.0@aar
Error:| | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | \--- com.google.android.gms:play-services-tasks:9.2.1@aar
Error:| | \--- com.google.android.gms:play-services-basement:9.2.1@aar
Error:| | \--- com.android.support:support-v4:25.4.0@aar
Error:| | +--- com.android.support:support-compat:25.4.0@aar
Error:| | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | +--- com.android.support:support-media-compat:25.4.0@aar
Error:| | | +--- com.android.support:support-annotations:25.4.0@jar
Error:| | | \--- com.android.support:support-compat:25.4.0@aar
Error:| | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | +--- com.android.support:support-core-utils:25.4.0@aar
Error:| | | +--- com.android.support:support-annotations:25.4.0@jar
Error:| | | \--- com.android.support:support-compat:25.4.0@aar
Error:| | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | +--- com.android.support:support-core-ui:25.4.0@aar
Error:| | | +--- com.android.support:support-annotations:25.4.0@jar
Error:| | | \--- com.android.support:support-compat:25.4.0@aar
Error:| | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | \--- com.android.support:support-fragment:25.4.0@aar
Error:| | +--- com.android.support:support-compat:25.4.0@aar
Error:| | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | +--- com.android.support:support-media-compat:25.4.0@aar
Error:| | | +--- com.android.support:support-annotations:25.4.0@jar
Error:| | | \--- com.android.support:support-compat:25.4.0@aar
Error:| | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | +--- com.android.support:support-core-ui:25.4.0@aar
Error:| | | +--- com.android.support:support-annotations:25.4.0@jar
Error:| | | \--- com.android.support:support-compat:25.4.0@aar
Error:| | | \--- com.android.support:support-annotations:25.4.0@jar
Error:| | \--- com.android.support:support-core-utils:25.4.0@aar
Error:| | +--- com.android.support:support-annotations:25.4.0@jar
Error:| | \--- com.android.support:support-compat:25.4.0@aar
Error:| | \--- com.android.support:support-annotations:25.4.0@jar
尝试使用建议的解决方案(没有configurations.all {...})它仍然出错:
Warning:Conflict with dependency 'com.android.support:support-media-compat' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
Warning:Conflict with dependency 'com.android.support:support-compat' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
Warning:Conflict with dependency 'com.android.support:support-core-ui' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
Warning:Conflict with dependency 'com.android.support:support-core-utils' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
Warning:Conflict with dependency 'com.android.support:support-v4' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
Warning:Conflict with dependency 'com.android.support:support-fragment' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
Warning:Conflict with dependency 'com.android.support:support-annotations' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
Warning:Conflict with dependency 'com.android.support:support-media-compat' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
Warning:Conflict with dependency 'com.android.support:support-compat' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
Warning:Conflict with dependency 'com.android.support:support-core-ui' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
Warning:Conflict with dependency 'com.android.support:support-core-utils' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
Warning:Conflict with dependency 'com.android.support:support-v4' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
Warning:Conflict with dependency 'com.android.support:support-fragment' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
Warning:Conflict with dependency 'com.android.support:support-annotations' in project 'helloworldtest'. Resolved versions for app (25.4.0) and test app (25.0.1) differ.
摇篮:
configurations.all {
exclude group:"com.android.support", module: "support-v4"
exclude group:"com.android.support", module: "support-annotations"
exclude group:"com.android.support", module: "support-compat"
exclude group:"com.android.support", module: "support-core-utils"
exclude group:"com.android.support", module: "support-core-utils"
}
List ExGroups = [ 'com.android.support' ]
List ExModules = [ 'support-annotations', 'support-compat', 'support-core-utils', 'support-media-compat' ]
dependencies {
testCompile 'junit:junit:4.11'
compile 'com.android.support:support-v4:25.0.1'
// androidTestCompile 'com.android.support:support-v4:25.0.1'
androidTestCompile ('com.android.support:support-v4:25.0.1') {
ExGroups.each { exclude group: '$it' }
ExModules.each { exclude module: '$it' }
}
// androidTestCompile 'com.jayway.android.robotium:robotium-solo:4.3.1'
// androidTestCompile files('libs/android-junit-report-1.5.8.jar')
// // dependencies for uiautomator
// androidTestCompile 'com.android.support.test:runner:0.2'
// androidTestCompile 'com.android.support.test:rules:0.2'
// androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.0'
// after adding this line it got error
//compile 'com.zone.android.identity:account:1.0.0’
compile ('com.zone.android.identity:account:1.0.0){
ExGroups.each { exclude group: '$it' }
ExModules.each { exclude module: '$it' }
}
}
===首发:
正在测试一个lib,在拉入它之前,应用程序只是一个简单的“hello world”'测试应用。它与gradle的依赖项一起工作正常。然后在gradle的依赖项中为lib添加了这一行:
compile 'com.zone.android.data:account:1.0.0’
然后出现错误:
Conflict with dependency 'com.android.support:support-media-compat' in project 'helloworld'.
Resolved versions for app (25.4.0) and test app (25.0.1) differ.
在gradle的依赖项中,如果将这两行更改为25.4.0就可以了。
compile 'com.android.support:support-v4:25.0.1' //<== change to 25.4.0
androidTestCompile 'com.android.support:support-v4:25.0.1' //<== change to 25.4.0
问题是app(25.4.0)的已解决版本在哪里?在gradle中看不到指定的25.4.0。
为什么在添加这一行之后:compile&#39; com.zone.android.data:account:1.0.0'然后它开始显示错误?
如果它是由这个lib com.zone.android.data引起的,我们可以假设它指定了一些不同于我们项目正在使用的版本,这是否意味着我们必须使用与lib / sdk版本相同的版本已经使用过(我们怎么知道它正在使用什么版本?如果lib使用了一些旧版本而我的应用程序想要使用更新的版本怎么办?)
那么,如果使用不同版本(或未知版本)的lib / sdk,最好的做法是什么呢?
dependencies {
testCompile 'junit:junit:4.11'
compile 'com.android.support:support-v4:25.0.1'
androidTestCompile 'com.android.support:support-v4:25.0.1'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:4.3.1'
androidTestCompile files('libs/android-junit-report-1.5.8.jar')
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.0'
// after adding this line it started to get error
compile 'com.zone.android.data:account:1.0.0’
}
答案 0 :(得分:0)
这是因为库包含:
compile 'com.zone.android.data:account:1.0.0'
已包含支持media-compat。因此,您需要从中排除支持库并使用项目支持库。你可以通过使用类似的东西来实现它:
compile ('com.zone.android.data:account:1.0.0') {
exclude group: 'com.android.support', module: 'support-media-compat' // or support-v4
}
请注意 该库可能需要 25.4.0 支持库,因为特定的API方法不在以前的支持中图书馆。所以,你需要彻底测试它。