您的位置:首页 > 移动开发 > Android开发

Android打包那些事

2016-04-25 15:17 435 查看

出处

Android打包那些事

下面是做的一些笔记

多渠道打包

"360"{
manifestPlaceholders = [channel:"360"]
}


如果渠道名是数字开头,则必须加引号

build-type中的参数

// minifyEnabled 混淆处理
// shrinkResources 去除无用资源
// signingConfig 签名
// proguardFiles 混淆配置
// applicationIdSuffix 增加APP ID的后缀
// debuggable 是否保留调试信息


自定义输出apk名称

android {
// rename the apk with the version name
// add output file sub folder by build type
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(
output.outputFile.parent + "/${variant.buildType.name}",
"ganchai-${variant.buildType.name}-${variant.versionName}-${variant.productFlavors[0].name}.apk".toLowerCase())
}
}
}


额外信息

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
(类型,名称,方法名)
resValue "string","build_time",buildTime()
resValue "string","build_host",buildHost()
}
}
def buildTime(){
//获取当前时间
return new Date().format("yyyy-MM-dd HH:mm:ss")
}

def buildHost(){
//获取当前计算机名称
return System.getProperty("user.name") + "@" + InetAddress.localHost.hostName
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: