我正在更新一个项目,其中包含许多不同的库和风格。我能够解决项目中的所有库,但在更新应用程序 build.gradle 时遇到问题。下面是错误和 gradle 的。我显然误解了文档,找不到正确的解决方案。如何在应用程序 build.gradle 级别解决此同步问题?
错误
Unable to resolve dependency for ':app@magicDebug/compileClasspath': Could not resolve project :vnfmdata.
Could not resolve project :vnfmdata.
Required by:
project :app
> Project :app declares a dependency from configuration 'implementation' to configuration 'regularDebug' which is not declared in the descriptor for project :vnfmdata.
应用构建.gradle
android {
...
flavorDimensions flavor.default
productFlavors {
...
magic {
...
flavorDimensions flavor.default
// missingDimensionStrategy flavor.regular, flavor.regular
// matchingFallbacks = [flavor.regular]
dependencies {
...
implementation project(':vnfmdata')
// implementation project(path: ':vnfmdata', configuration: 'regularDebug') // pre gradle 3.0
...
}
}
}
}
___gradle下面的两个libs sync fine ___
vnfmdata build.gradle
android {
...
flavorDimensions flavor.no_meridian, flavor.regular
productFlavors {
regular {
dimension flavor.regular
// Forces regular's flavor to point on LocationService meridian's flavor
// because their flavors' name are different
matchingFallbacks = [flavor.meridian]
}
no_meridian {
dimension flavor.no_meridian
// Will automatically point on LocationService no_meridian's flavor
// because they both have the same name
}
}
buildTypes {
release {}
}
...
}
dependencies {
...
implementation project(':vnlocationservice')
...
}
vnlocationservice build.gradle
android {
...
/** Flavors **/
flavorDimensions flavor.meridian, flavor.no_meridian
productFlavors {
no_meridian {
dimension flavor.no_meridian
}
meridian {
dimension flavor.meridian
dependencies {
implementation project(':third:Sas-Android')
implementation deps.support.compat_v26
implementation deps.play.ads
implementation deps.play.location
implementation deps.localytics
implementation 'com.arubanetworks.meridian:meridian:+@aar'
}
}
}
buildTypes {
release {}
}
...
}
dependencies {
...
}
最佳答案
你的模块目前没有维度,所以你应该只使用一个维度,比如你应用的 build.gradle flavorDimensions flavor.default
。
(请参阅 documentation 的这一部分,并查看使用 flavorDimensions 时的多个输出是什么。)
vnfmdata
...
//With only one dimension, you can omit 'dimension' into your flavors
flavorDimensions flavor.default
productFlavors {
regular {
dimension flavor.default
...
}
no_meridian {
dimension flavor.default
}
}
定位服务
...
//With only one dimension, you can omit 'dimension' into your flavors
flavorDimensions flavor.default
productFlavors {
no_meridian {
dimension flavor.default
}
meridian {
dimension flavor.default
dependencies {
...
}
}
}
关于android - 升级到 gradle 3.+ 时出现应用程序 build.gradle 同步问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49720440/