博客
关于我
打包命名
阅读量:356 次
发布时间:2019-03-04

本文共 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);                    }                }            }

转载地址:http://iqpr.baihongyu.com/

你可能感兴趣的文章
MySQL 和 PostgreSQL,我到底选择哪个?
查看>>
mysql 四种存储引擎
查看>>
MySQL 在并发场景下的问题及解决思路
查看>>
MySQL 在控制台插入数据时,中文乱码问题的解决
查看>>
MySQL 基础架构
查看>>
MySQL 基础模块的面试题总结
查看>>
MySQL 处理插入重主键唯一键重复值办法
查看>>
MySQL 备份 Xtrabackup
查看>>
mysql 复杂查询_mysql中复杂查询
查看>>
mYSQL 外键约束
查看>>
mysql 多个表关联查询查询时间长的问题
查看>>
mySQL 多个表求多个count
查看>>
mysql 多字段删除重复数据,保留最小id数据
查看>>
MySQL 多表联合查询:UNION 和 JOIN 分析
查看>>
MySQL 大数据量快速插入方法和语句优化
查看>>
mysql 如何给SQL添加索引
查看>>
mysql 字段区分大小写
查看>>
mysql 字段合并问题(group_concat)
查看>>
mysql 字段类型类型
查看>>
MySQL 字符串截取函数,字段截取,字符串截取
查看>>