我正在使用的构建文件如下。我想实现我的付费版本不包含广告库。我只包括免费风格的广告库。但它们存在于所有版本中。
我应该如何更改我的构建文件以获得广告库免费付费版本?
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
tasks.withType(Compile) {
options.encoding = "UTF-8"
}
apply plugin: 'android'
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile fileTree(dir: 'src/main/libs', include: '*.jar')
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:18.0.+'
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
versionCode 25
versionName "1.9.1"
minSdkVersion 9
targetSdkVersion 18
packageName 'com.example.myproject'
}
signingConfigs {
debug {
storeFile file("your path")
}
release {
storeFile file("your path")
storePassword ""
keyAlias ""
keyPassword ""
}
}
buildTypes {
debug {
packageNameSuffix '.debug'
versionNameSuffix '-DEBUG'
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
}
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java']
res.srcDirs = ['src/main/res']
assets.srcDirs = ['src/main/assets']
}
}
flavorGroups 'market', 'version'
productFlavors {
google {
flavorGroup 'market'
}
amazon {
flavorGroup 'market'
}
slideme {
flavorGroup 'market'
}
free {
flavorGroup "version"
dependencies {
compile fileTree(dir: 'src/free/libs', include: '*.jar')
}
}
paid {
flavorGroup "version"
packageName = android.defaultConfig.packageName + ".paid"
}
}
android.sourceSets.amazon {
assets.srcDirs = ['src/amazon/assets']
res.srcDirs = ['src/amazon/res']
java.srcDirs = ['src/amazon/java']
}
android.sourceSets.slideme {
assets.srcDirs = ['src/slideme/assets']
res.srcDirs = ['src/slideme/res']
java.srcDirs = ['src/slideme/java']
}
android.sourceSets.free {
manifest.srcFile 'src/free/AndroidManifest.xml'
assets.srcDirs = ['src/free/assets']
res.srcDirs = ['src/free/res']
java.srcDirs = ['src/free/java']
}
android.sourceSets.paid {
assets.srcDirs = ['src/paid/assets']
res.srcDirs = ['src/paid/res']
java.srcDirs = ['src/paid/java']
}
}