仅具有调试和发布buildTypes的应用程序如何使用多样式库?
我有一个包含两个模块的项目:app
和mymodule
。
app
模块仅具有调试和发布buildTypes就没有味道。这是应用build.gradle
。
apply plugin: 'com.android.application'
android {
default {
....
}
buildTypes {
debug {
}
release {
}
}
}
dependencies {
}
mymodule
有两种形式:登录和注册,它们共享相同的基本代码。这是mymodule build.gradle
。
apply plugin: 'com.android.library'
android {
default {
....
}
buildTypes {
debug {
}
release {
}
}
flavorDimensions 'version'
productFlavors {
login {
}
registration {
}
}
}
dependencies {
}
在mymodule
中,将代码分成这样的源集,以便我可以构建 login.aar 或 registration.aar ,但也可以让它们共享src/main/java
的基本代码。我还想在mymodule
模块中使用app
。
|-src/main/java/
|-src/login/java
|-src/registration/java
这是settings.gradle
。
include ':app', ':mymodule'
我已将依赖项implementation project(':mymodule')
添加到应用程序build.gradle
中,但收到以下错误:
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