我有一个带有风味组和风味的 gradle 项目。将每个口味的 AndroidManifest.xml 放在哪里,以便与主清单合并?例如,现在我将 AndroidManifest.xml 放入“amazon”文件夹。它的权限比主权限多。但是这两个没有合并。这只是清单问题。其他资源文件(如字符串和可绘制对象)会正确合并。
我的 build.gradle 文件是:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.6'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['resources']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
defaultConfig {
...
}
signingConfigs {
debug {
storeFile file("debug.keystore")
}
release {
...
}
}
buildTypes {
debug {
debuggable true
jniDebugBuild true
signingConfig signingConfigs.debug
packageNameSuffix ".debug"
versionNameSuffix ".debug"
}
release {
debuggable false
jniDebugBuild false
signingConfig signingConfigs.release
}
}
flavorGroups "version", "market"
productFlavors {
amazon {
flavorGroup "market"
buildConfig "public static final int COMPILATION = 1;"
}
google {
flavorGroup "market"
buildConfig "public static final int COMPILATION = 0;"
}
lite {
flavorGroup "version"
packageName = "package.name.lite"
}
full {
flavorGroup "version"
packageName = "package.name.full"
}
}
android.sourceSets.amazon {
res {
srcDir "amazon"
}
manifest {
srcFile "amazon/AndroidManifest.xml"
}
}
android.sourceSets.google {
res {
srcDir "google"
}
}
android.sourceSets.full {
res {
srcDir "full"
}
}
android.sourceSets.lite {
res {
srcDir "lite"
}
}
}
编辑:
似乎清单实际上正在合并(我没有注意到它,因为权限已添加到文件底部)。但它仅在原始清单文件中缺少一个标签并且存在于风味清单中时才有效。有时我想覆盖现有标签的属性,然后它不起作用。是 gradle 问题还是我做错了什么?