
打包命名
发布日期:2021-05-07 19:02:35
浏览次数:11
分类:技术文章
本文共 2471 字,大约阅读时间需要 8 分钟。
android { signingConfigs { config { keyAlias 'myapp' keyPassword '123456' storeFile file('H:/android/project/AndroidFire-master/myapp.jks') storePassword '123456' } } compileSdkVersion 24 buildToolsVersion "25" defaultConfig { applicationId "................" minSdkVersion 15 targetSdkVersion 24 versionCode 10 versionName "1.1.0" } buildTypes { release { buildConfigField "boolean", "LOG_DEBUG", "false" //混淆 minifyEnabled false //Zipalign优化 zipAlignEnabled true // 移除无用的resource文件 shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' //apk命名 android.applicationVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith('.apk')) { //这里修改apk文件名 def fileName = "AndroidFire-${defaultConfig.versionCode}-${defaultConfig.versionName}-${releaseTime()}.apk" output.outputFile = new File(outputFile.parent, fileName) } } } signingConfig signingConfigs.config } debug { buildConfigField "boolean", "LOG_DEBUG", "true" minifyEnabled false zipAlignEnabled false shrinkResources false } } //设置虚拟机堆内存空间大小,避免在编译期间OOM dexOptions { incremental true javaMaxHeapSize "4g" } //打包不检查 lintOptions { checkReleaseBuilds false abortOnError false }}
如果你的classPath>3.0 会报错 应当使用
applicationVariants.all { variant -> //批量修改Apk名字 variant.outputs.all { output -> if (!variant.buildType.isDebuggable()) { //获取签名的名字 variant.signingConfig.name //要被替换的源字符串 def sourceFile = "-${variant.flavorName}-${variant.buildType.name}" //替换的字符串 def replaceFile = "gxb_v${variant.versionName}_${variant.productFlavors[0].name}_${variant.buildType.name}" outputFileName = output.outputFile.name.replace(sourceFile, replaceFile); } } }
发表评论
最新留言
网站不错 人气很旺了 加油
[***.192.178.218]2025年04月05日 12时05分21秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
android用视频当做背景
2019-03-04
android 用action拦截打电话界面
2019-03-04
打包命名
2019-03-04
Android UI效果篇-(3)用属性动画实现收缩菜单
2019-03-04
Android反编译-揭秘猎豹设置默认浏览器逻辑
2019-03-04
错误: 编码GBK的不可映射字符
2019-03-04
html img点击跳转网页
2019-03-04
Python-Url编码和解码
2019-03-04
windows环境下生成ssh keys
2019-03-04
2019年一个程序员的回顾与成长计划
2019-03-04
CSDN博客自定义栏目——Google、百度、必应站内搜索框
2019-03-04
vue 双项绑定的实例 货币转换
2019-03-04
vue if else用法。
2019-03-04
vue 官方实例教程 markdown demo
2019-03-04
CSS border-style 属性
2019-03-04
Python数据类型 列表、元组、集合、字典的区别和相互转换
2019-03-04