的事情比较复杂一点。 我的gradle上实验0.8.0
在您需要的库测试:
model{
android {
...
publishNonDefault true
productFlavors {
create("flavor1") {
}
create("flavor2") {
}
}
}
}
上的应用程序,你需要:
model {
android {
...
publishNonDefault true
productFlavors {
create("flavor1") {
}
create("flavor2") {
}
}
}
}
//after the model is closed !!
configurations {
flavor1DebugCompile
flavor1ReleaseCompile
flavor2DebugCompile
flavor2ReleaseCompile
}
dependencies {
...
flavor1DebugCompile project(path: ':mylibrary', configuration: 'flavor1Debug')
flavor1ReleaseCompile project(path: ':mylibrary', configuration: 'flavor1Release')
flavor2DebugCompile project(path: ':mylibrary', configuration: 'flavor2Debug')
flavor2ReleaseCompile project(path: ':mylibrary', configuration: 'flavor2Release')
}
希望,如果你完全运行组装你会得到2个apk,每个味道一个。 我已经从cmd中使用“./gradlew build”并获得了它们。 请注意,对于你的lib,你会得到一个AAR每个味道太
这没有用。 – dragostis
这个例子在'0.2.1'上适合你吗?当然有适当的语法。库中的'android.productFlavors'和主项目中的'compile project(':mylibrary')'。 – dragostis
语法正确,并且与应用程序模块一起工作良好。我不知道它如何与图书馆合作。在我看来,你应该移动主模块中的味道(我从未在库中看到过味道) –