Gradle多渠道打包
16lz
2021-12-04
今天以umeng为例讲解gradle的多渠道打包
1,在manifest里面配置如下信息
<meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}"/>2,在build.gradle里进行如下配置
def releaseTime() { return new Date().format("yyyy-MM-dd")}android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { applicationId "com.guojinbao.app" minSdkVersion 9 targetSdkVersion 23 versionCode 5 versionName "1.5.0" // dex突破65535的限制// multiDexEnabled true // 默认是umeng的渠道 manifestPlaceholders = [UMENG_CHANNEL_VALUE: "hwyy"] } lintOptions { checkReleaseBuilds false abortOnError false } packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/license.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/notice.txt' exclude 'META-INF/ASL2.0' } compileOptions { sourceCompatibility JavaVersion.VERSION_1_6 targetCompatibility JavaVersion.VERSION_1_6 } signingConfigs { release { storeFile file("../guojinbao_release.jks") storePassword "VmVTQi6n" keyAlias "guojinbao" keyPassword "VmVTQi6n" } } buildTypes { release { zipAlignEnabled true shrinkResources true minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release applicationVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith('.apk')) { // 输出apk名称为guojinbao_v1.0_2015-01-15_wandoujia.apk def fileName = "guojinbao_v${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}.apk" output.outputFile = new File(outputFile.parent, fileName) } } } } } // 友盟多渠道打包 productFlavors { umeng {} sjzs_360 {} sjzs_bd {} sjzs_91 {} yyb {} xmsd {} hwyy {} pp_azzs {} oppo_sd {} wdj {} anzhi {} anzhuosc {} anzhuoyuan {} jfw {} lxlsd {} mmy {} yiyonghui {} yingyonghui {} yysc {} kuchuan {} sg_sjzs {} wy_yyzx {} ltwo {} azsc_3g {} sn_yysd {} ndw {} meizu {} azzj {} tykj {} mmsh {} lqsc {} xlyy {} anzhuosd {} alsc {} mgsc {} tongbutui {} vivo_sjzs {} tyyy {} kupai {} zx_yysd {} } productFlavors.all { flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name] }3,使用android studio右侧gradle功能
注意这里是app目录下
更多相关文章
- NPM 和webpack 的基础使用
- [APP] Android(安卓)开发笔记 006-使用短信验证SDK进行短信验证
- Android(安卓)5.x特性概览二
- android listview custom style 自定义样式
- android:制作system.img(yaffs2)镜像
- Android读取Excel文件
- Android(安卓)Manifest文件中meta-data的配置读取
- Android(安卓)tabhost让选中项加上背景图
- android与.NET webservice