針對庫項目
//庫項目,假設(shè)其項目名稱為MyLib
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
publishNonDefault true //不要忘了這一行
...
productFlavors {
google {//針對谷歌Google Play的
}
xiaomi {//針對小米應(yīng)用商店
}
...
}
}
主項目
//主項目
apply plugin: 'com.android.application'
android {
...
compileSdkVersion 23
buildToolsVersion '23.0.3'
...
productFlavors {
google { //針對谷歌Google Play的
}
tencent { //針對騰訊應(yīng)用寶
}
qihoo { //針對360
}
...
}
...
}
dependencies {
...
//此處的path對應(yīng)的值為上面的庫項目
googleCompile project(path: ':MyLib', configuration: 'googleRelease')
tencentCompile project(path: ':MyLib', configuration: 'xiaomiRelease')
qihooCompile project(path: ':MyLib', configuration: 'xiaomiRelease')
...
}