Question
How can an app with only debug & release buildTypes use a multi flavor library?
Details
I have a project containing two modules: app
and mymodule
.
The app
module has no flavor with only debug and release buildTypes. This is the app build.gradle
.
apply plugin: 'com.android.application'
android {
default {
....
}
buildTypes {
debug {
}
release {
}
}
}
dependencies {
}
The mymodule
has two flavors: login and registration which share the same base codes. This is mymodule build.gradle
.
apply plugin: 'com.android.library'
android {
default {
....
}
buildTypes {
debug {
}
release {
}
}
flavorDimensions 'version'
productFlavors {
login {
}
registration {
}
}
}
dependencies {
}
In mymodule
, the codes are separated into source set like this so that I can build login.aar or registration.aar, but also let them share the base code from src/main/java
. I also would like to use mymodule
in app
module.
|-src/main/java/
|-src/login/java
|-src/registration/java
This is settings.gradle
.
include ':app', ':mymodule'
What I’ve tried
I’ve added the dependency implementation project(':mymodule')
into app build.gradle
, but I received the following error:
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :mymodule.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :mymodule.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :mymodule.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project :mymodule.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve project :mymodule.
Show Details
Affected Modules: app