博客
关于我
打包命名
阅读量:348 次
发布时间: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/

你可能感兴趣的文章
IEEE期刊缩写(常见的电机控制类期刊)
查看>>
VS中使用c++函数显示找不到标识符
查看>>
排列组合
查看>>
Why Software Development Methodologies Suck?
查看>>
怎样从0开始搭建一个测试框架_0
查看>>
JPEG压缩技术
查看>>
Algorithm: K-Means
查看>>
《C++ Concurrency in Action》读书笔记四 c++内存模型和原子类型
查看>>
Leetcode No.104 Maximum Depth of Binary Tree 遍历二叉树的深度
查看>>
Vmware Pro 12 上安装CentOS 7 64位
查看>>
《Windows程序设计》读书笔八 计时器
查看>>
《Windows程序设计》读书笔十 菜单和其他资源
查看>>
开发基于MFC的ActiveX控件的时候的一些消息处理
查看>>
一个C/C++ 命令行参数处理的程序
查看>>
使用ffmpeg 对视频做resize
查看>>
一个使用Java语言描述的矩阵旋转的例子
查看>>
两款用于检测内存泄漏的软件
查看>>
王爽 《汇编语言》 读书笔记 三 寄存器(内存访问)
查看>>
IDEA/eclipse集成阿里巴巴Java开发规约插件
查看>>
IDEA出现问题:Received fatal alert: protocol_version 解决方案
查看>>