Android 多渠道打包瘦馍、多id歼秽、多名稱打包
簽名設(shè)置
signingConfigs {
debug {//開發(fā)
storeFile file('D:/key_store/invest_andoird_keystore_debug.jks')
keyAlias '*****'
storePassword '*****'
keyPassword '*****'
}
FXBTest {//測試
storeFile file('D:/key_store/invest_andoird_keystore_debug.jks')
keyAlias '*****'
storePassword '*****'
keyPassword '*****'
}
release {//生產(chǎn)
storeFile file('D:/key_store/invest_andoird_keystore_debug.jks')
keyAlias 'zhoujianxiong'
storePassword 'tf2016'
keyPassword 'tf2016'
}
}
buildTypes
buildTypes {
debug {
debuggable true //是否允許debug
minifyEnabled true //不啟用Proguard
zipAlignEnabled false //是否啟用zipAlign壓縮
buildConfigField 'boolean', 'IS_DEBUG', 'true' //是否輸出日志
buildConfigField 'boolean', 'IS_SHUT_DOWN_CONFIG', 'false' //是否停機
buildConfigField 'String', 'SERVER_URL', DEBUG_SERVER_URL //對應(yīng)服務(wù)器地址
buildConfigField 'String', 'FILE_SERVER_URL', FILE_TEST_SERVER_URL //對應(yīng)文件服務(wù)器地址
buildConfigField 'String', 'UMENG_APPKEY', TEST_UMENG_APPKEY //友盟appkey
buildConfigField 'String', 'UMENG_MESSAGE_SECRET', TEST_UMENG_MESSAGE_SECRET //友盟UMENG_MESSAGE_SECRET
buildConfigField 'String', 'WEI_XIN_SDK_KEY', TEST_WEI_XIN_SDK_APP_ID //微信appkey
buildConfigField 'String', 'WEI_XIN_SDK_SECRET', TEST_WEI_XIN_SDK_APP_SECRET //微信_SECRET
resValue "string", "app_name_fengxiangibao", "峰向標開發(fā)" //APP名稱
manifestPlaceholders = [
"UMENG_APPKEY" : TEST_UMENG_APPKEY,
"UMENG_MESSAGE_SECRET": TEST_UMENG_MESSAGE_SECRET
]
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
//測試環(huán)境
FXBTest {
debuggable true //是否允許debug
minifyEnabled false //不啟用Proguard
zipAlignEnabled true //是否啟用zipAlign壓縮
buildConfigField 'boolean', 'IS_DEBUG', 'true' //是否輸出日志
buildConfigField 'boolean', 'IS_SHUT_DOWN_CONFIG', 'false' //是否停機
buildConfigField 'String', 'SERVER_URL', TEST_SERVER_URL //對應(yīng)服務(wù)器地址
buildConfigField 'String', 'FILE_SERVER_URL', FILE_TEST_SERVER_URL //對應(yīng)文件服務(wù)器地址
buildConfigField 'String', 'UMENG_APPKEY', TEST_UMENG_APPKEY //友盟appkey
buildConfigField 'String', 'UMENG_MESSAGE_SECRET', TEST_UMENG_MESSAGE_SECRET //友盟UMENG_MESSAGE_SECRET
buildConfigField 'String', 'WEI_XIN_SDK_KEY', TEST_WEI_XIN_SDK_APP_ID //微信appkey
buildConfigField 'String', 'WEI_XIN_SDK_SECRET', TEST_WEI_XIN_SDK_APP_SECRET //微信_SECRET
resValue "string", "app_name_fengxiangibao", "***" //APP名稱
manifestPlaceholders = [
"UMENG_APPKEY" : TEST_UMENG_APPKEY,
"UMENG_MESSAGE_SECRET": TEST_UMENG_MESSAGE_SECRET
]
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.FXBTest
}
release {
debuggable false //是否允許debug
minifyEnabled true //啟用Proguard
zipAlignEnabled true //是否啟用zipAlign壓縮
buildConfigField 'boolean', 'IS_DEBUG', 'false' //是否輸出日志
buildConfigField 'boolean', 'IS_SHUT_DOWN_CONFIG', 'true' //是否停機
buildConfigField 'String', 'SERVER_URL', RELEASE_SERVER_URL //對應(yīng)服務(wù)器地址
buildConfigField 'String', 'FILE_SERVER_URL', FILE_SERVER_URL //對應(yīng)文件服務(wù)器地址
buildConfigField 'String', 'UMENG_APPKEY', RELEASE_UMENG_APPKEY //友盟appkey
buildConfigField 'String', 'UMENG_MESSAGE_SECRET', RELEASE_UMENG_MESSAGE_SECRET //友盟UMENG_MESSAGE_SECRET
buildConfigField 'String', 'WEI_XIN_SDK_KEY', WEI_XIN_SDK_APP_ID //微信appkey
buildConfigField 'String', 'WEI_XIN_SDK_SECRET', WEI_XIN_SDK_APP_SECRET //微信_SECRET
resValue "string", "app_name_fengxiangibao", "***" //APP名稱
manifestPlaceholders = [
"UMENG_APPKEY" : RELEASE_UMENG_APPKEY,
"UMENG_MESSAGE_SECRET": RELEASE_UMENG_MESSAGE_SECRET
]
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
多渠道打包
flavorDimensions 'api'
productFlavors {
Fntest {
// 測試版本號
versionName VERSION_NAME_TEST
// 測試包名(測試友盟推送時,需將包名改成正式 包名情组,否則會提示ResClass未初始化 )
applicationId "c****ao.test"
}
FengXiangBiao {}
fir {}
xiaomi {}
qh360 {}
vivo {}
oppo {}
tencent {}
anzhi {}
sougou {}
meizu {}
}
productFlavors.all {
flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
}
打包重命名
//將release版本的包名重命名燥筷,加上版本及日期
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
def flavorName = variant.productFlavors[0].name;
def versionName = variant.productFlavors[0].versionName;
if (versionName == null) {
versionName = android.defaultConfig.versionName;
}
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def newName;
def buildType = variant.buildType.name;
if (buildType.equals('release')) {
newName = "FengXiangBiaoV${versionName}_${flavorName}.apk"
} else if (buildType.equals('debug')) {
newName = "FengXiangBiaoV${versionName}_debug_${releaseTime()}.apk"
} else {
newName = "FengXiangBiaoV${versionName}_test_${releaseTime()}.apk"
}
outputFileName = newName
}
}
}
// 生成版本的時間
def releaseTime() {
return new Date().format("yyyyMMddHH")
}
// APP的VersionCode
def generateVersionCode() {
return new Date().format("yyyyMMddHH", TimeZone.getTimeZone("GMT+8"))
}
gradle.properties
VERSION_DEVELOP=0;
VERSION_PRO=1;
VERSIONCODE = 100
VERSIONNAME = 4.3.3
---
其他參數(shù)
---