I'm working on a multi-flavor app
. (gradle files below)
It uses a library called tracker
that follow the same flavors internal
and external
Now for the tricky part, come a new module called feature
, this one has no flavor but it needs the tracker
as dependency
app.gradle:
android {
buildTypes {
debug {
}
release {
}
}
flavorDimensions "target"
productFlavors {
internal {
dimension "target"
}
external {
dimension "target"
}
}
}
tracker.gradle:
android {
publishNonDefault true
buildTypes {
release {
}
debug {
}
}
flavorDimensions 'target'
productFlavors {
internal {
dimension "target"
}
external {
dimension "target"
}
}
}
feature.gradle:
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
}
}
}
dependencies {
implementation(
[...]
project(':tracker')
)
}
Here are the errors
when I try to gradle sync:
Unable to resolve dependency for ':feature@debug/compileClasspath': Could not resolve project :tracker.
Could not resolve project :tracker.
Required by:
project :feature
> Project :feature declares a dependency from configuration 'implementation' to configuration 'externalRelease' which is not declared in the descriptor for project :tracker.
Unable to resolve dependency for ':feature@debugAndroidTest/compileClasspath': Could not resolve project :tracker.
Could not resolve project :tracker.
[...]
My gradle version is 4.4.
In doc, Android developer and Android Plugin DSL Reference show that, should add follow code.
missingDimensionStrategy 'external'
missingDimensionStrategy 'target'
Android Plugin DSL Reference image
but it not work for me. Finally I add follow code in feature.gradle.
flavorDimensions 'target'
productFlavors {
internal {
dimension "target"
}
}