1.
<meta-data android:name="UMENG_CHANNEL" android:value=${UMENG_CHANNEL_VALUE} />
2.配置gradle
defaultConfig { applicationId "xx.xx.xx" minSdkVersion 10 targetSdkVersion 21 multiDexEnable true //突破应用方法数65535限制manifestPlaceholders = [UMENG_CHANNEL_VALUE:"test"]//默认渠道号
}productFlavors{buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'signingConfig signingConfigs.release//包名重命名(可选)
// applicationVariants.all{ variant->// variant.outputs.each{ output->
// def outFile = output.outputFile
// if(outFile!=null && outFile.name.endsWith(".apk")){
// def fileName = "${variant.productFlavors[0].name}"+".apk"
// output.outputFile = new File(outFile.parent,fileName);
// }
// }
// } //
} }
//签名配置文件signingConfigs{
debug{}
release{
storeFile file("xxxx")
storePasssord "xxxx"
keyAlias "xxxx"
keyPassword "xxxx"
}
}
yingyongbao{
//manifestPlaceholders = [UMENG_CHANNEL_VALUE:"yingyongbao"]
}
xiaomi{
//manifestPlaceholders = [UMENG_CHANNEL_VALUE:"xiaomi"]
}
}
//遍历
productFlavors.all{flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE:name]}
打包命令: ./gradlew assebmleRelease