博客
关于我
打包命名
阅读量: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/

你可能感兴趣的文章
MVC 区域功能
查看>>
MySQL FEDERATED 提示
查看>>
mysql generic安装_MySQL 5.6 Generic Binary安装与配置_MySQL
查看>>
Mysql group by
查看>>
MySQL I 有福啦,窗口函数大大提高了取数的效率!
查看>>
mysql id自动增长 初始值 Mysql重置auto_increment初始值
查看>>
MySQL in 太多过慢的 3 种解决方案
查看>>
MySQL InnoDB 三大文件日志,看完秒懂
查看>>
Mysql InnoDB 数据更新导致锁表
查看>>
Mysql Innodb 锁机制
查看>>
MySQL InnoDB中意向锁的作用及原理探
查看>>
MySQL InnoDB事务隔离级别与锁机制深入解析
查看>>
Mysql InnoDB存储引擎 —— 数据页
查看>>
Mysql InnoDB存储引擎中的checkpoint技术
查看>>
Mysql InnoDB存储引擎中缓冲池Buffer Pool、Redo Log、Bin Log、Undo Log、Channge Buffer
查看>>
MySQL InnoDB引擎的锁机制详解
查看>>
Mysql INNODB引擎行锁的3种算法 Record Lock Next-Key Lock Grap Lock
查看>>
mysql InnoDB数据存储引擎 的B+树索引原理
查看>>
mysql innodb通过使用mvcc来实现可重复读
查看>>
mysql insert update 同时执行_MySQL进阶三板斧(三)看清“触发器 (Trigger)”的真实面目...
查看>>