AndroidMainifest.xml
//假设这是某平台申请的keY
<meta-data android:name="com.baidu.lbsapi.API_KEY" android:value="ahEnNVoYM1krUNQRZaQ3OxyG" />
<span style="color:#333333;">apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "23.0.2" defaultConfig { applicationId "com.example.com.newproject" minSdkVersion 19 targetSdkVersion 21 versionCode 1 versionName "1.0" manifestPlaceholders = [UMENG_CHANNEL_VALUE: '默认是运行开发版本的值']//默认运行的值 } signingConfigs { release { storeFile file("test.jks") keyAlias "test" keyPassword "111111" storePassword "111111" } } productFlavors { dev{ applicationId "com.example.com.newproject" versionName "1.0" manifestPlaceholders.put("UMENG_CHANNEL_VALUE",'默认是运行开发版本的值') } google{ applicationId "com.test.google" versionName "1.0" manifestPlaceholders.put("UMENG_CHANNEL_VALUE",'google') } baidu{ applicationId "com.test.baidu" versionName "1.0" manifestPlaceholders.put("UMENG_CHANNEL_VALUE",'baidu')//'baidu'是替换AndroidManifest.xml的meta-data值 } } buildTypes { release { signingConfig signingConfigs.release //签名 minifyEnabled true //是否要压缩 proguardFile 'proguard-android.txt' //该文件直接放在app目录下 //多版本打包的配置 applicationVariants.all { variant -> variant.outputs.each { output -> if (output.outputFile != null && output.outputFile.name.endsWith('.apk') &&'release'.equals(variant.buildType.name)) { def apkFile = new File( output.outputFile.getParent(), "Mymoney_${variant.flavorName}_v${variant.versionName}_${buildTime()}.apk") output.outputFile = apkFile } } } } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:21.0.3' } //当前打包的时间 def buildTime() { def date = new Date() def formattedDate = date.format('yyyyMMdd') return formattedDate } </span><span style="color:#e8bf6a;"> </span>