【发布时间】:2016-03-22 14:06:10
【问题描述】:
我有两个模块一个 app 和一个 library 和 我使用的两个外部 Maven 库。
外部库略有不同,是根据构建风格与 maven 分类器一起选择的。
(子项目/模块)和(主模块)都使用基于风格的相同外部库。
我的问题是我无法控制/选择子项目库时 编译。
模块应用:
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
android {
productFlavors {
fOne {}
fTwo {}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:gridlayout-v7:22.2.1'
compile 'com.android.support:support-annotations:22.2.1'
// selecting the library based on the flavour
fOneCompile(group: 'com.xyz', name: 'SDK', version: '1.0', ext: 'aar')
fTwoCompile(group: 'com.xyz', name: 'SDK', version: '1.0', classifier: 'qa', ext: 'aar')
//<< the library also needs the com.xyz.SDK
fOneCompile project(path: ':library', configuration: "fOneCompile")
fTwoCompile project(path: ':library', configuration: "fTwoCompile")
}
模块库:
apply plugin: 'com.android.library'
android {
....
}
repositories{
jcenter()
flatDir{
dirs 'libs'
}
}
configurations {
fOne
fTwo
}
dependencies {
??? what goes here, flavours are not available ???
//the library also needs the com.xyz.SDK
fOneCompile(group: 'com.xyz', name: 'SDK', version: '1.0', ext: 'aar')
fTwoCompile(group: 'com.xyz', name: 'SDK', version: '1.0', classifier: 'qa', ext: 'aar')
}
模块 library 无法编译,因为它找不到 SDK 和我 需要根据正在编译的风格包含一个。
【问题讨论】:
-
" 应用插件:'com.android.library'" 将这个添加到 B
-
我的错,没有复制,不是问题。我已经更新了问题。
-
主项目的 'settings gradle' 有 "include ';projectB' "
-
在项目 A 的 cli 上 " ./gradlew --info --stacktrace :projectB:clean :projectB:assembleDebug "