android studio自动绑定,Android Studio 3.x 自动生成多渠道包

Android Studio 3.x  自动生成多渠道包

1)AndroidManifest清单文件中添加

完整如下:

2)module 的build.gradle中添加渠道及打包方法

apply plugin: ‘com.android.application‘

android {

compileSdkVersion 29

buildToolsVersion "29.0.3"

defaultConfig {

applicationId "com.demo.activityfragmentlifescyle"

minSdkVersion 16

targetSdkVersion 29

versionCode 1

versionName "1.0"

flavorDimensions "versionCode"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile(‘proguard-android-optimize.txt‘), ‘proguard-rules.pro‘

}

applicationVariants.all { variant ->

variant.outputs.all { output ->

def outputFile = output.outputFile

def fileName

if (outputFile != null && outputFile.name.endsWith(‘.apk‘)) {

if (variant.buildType.name.equals(‘release‘)) {//如果是release包

fileName = "cbx_release_v${defaultConfig.versionName}.apk"

} else if (variant.buildType.name.equals(‘debug‘)) {//如果是debug包

fileName = "cbx_debug_v${defaultConfig.versionName}.apk"

}

outputFileName = fileName

}

}

}

}

productFlavors{

baidu{}

_91{}

xiaomi{}

huawei{}

}

productFlavors.all {

flavor -> flavor.manifestPlaceholders = [MAT_CHANNEL_VALUE: name]

}

}

def releaseTime() {

return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))

}

dependencies {

implementation fileTree(dir: ‘libs‘, include: [‘*.jar‘])

implementation ‘androidx.appcompat:appcompat:1.1.0‘

implementation ‘androidx.constraintlayout:constraintlayout:1.1.3‘

implementation ‘androidx.legacy:legacy-support-v4:1.0.0‘

testImplementation ‘junit:junit:4.12‘

androidTestImplementation ‘androidx.test.ext:junit:1.1.1‘

androidTestImplementation ‘androidx.test.espresso:espresso-core:3.2.0‘

}

原文:https://www.cnblogs.com/zhou2016/p/12922258.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值