我有一个依赖项'com.liferay.mobile:liferay-screens:2.1.4'
,例如,我想强迫它使用'com.android.support:support-v4:28.0.0'
。
我该如何仅对gradle中的liferay-screens
依赖项进行强制?
我已经像下面那样完成了,但是会出错:
ERROR: Could not find method com.liferay.mobile:liferay-screens:2.1.4() for arguments [build_e4u81lzxji4bi1lau20a1sng2$_run_closure3$_closure7@2be4e1d1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
implementation 'com.liferay.mobile:liferay-screens:2.1.4' {
resolutionStrategy.force 'com.android.support:support-v4:28.0.0'
}
答案 0 :(得分:1)
在Gradle 6.0中,我的建议是在constraint
中使用新的strictly
semantics:
dependencies {
implementation 'com.liferay.mobile:liferay-screens:2.1.4'
constraints {
implementation('com.android.support:support-v4') {
version {
strictly '28.0.0' // Will make sure that library uses that version in your build
}
}
}
}
在Gradle 6.0之前,建议采用您的方式,但是语法需要进行调整:
dependencies {
implementation 'com.liferay.mobile:liferay-screens:2.1.4'
}
configurations.all {
// Will force that dependency version everywhere
resolutionStrategy.force 'com.android.support:support-v4:28.0.0'
}
在您尝试表达的情况下,强制仅在给定上下文中的 版本实际上是没有意义的。重要的是,您希望总体分辨率始终使用该特定版本。