首页 > 学院 > 开发设计 > 正文

安卓自定义打包生成的文件名字

2019-11-08 00:26:40
字体:
来源:转载
供稿:网友

在项目主module下面添加下面的代码,红色部分代码

apply plugin: 'com.android.application'apply plugin: 'com.neenbedankt.android-apt'def bugtagsConfig = rootPRoject.ext.bugtagsConfig;android {    // for bugtags    useLibrary 'org.apache.http.legacy'    compileSdkVersion COMPILE_SDK_VERSION    buildToolsVersion BUILD_TOOLS_VERSION    dataBinding {        enabled = true    }    defaultConfig {        applicationId "com.mem.MacaoLife"        minSdkVersion MIN_SDK_VERSION        targetSdkVersion TARGET_SDK_VERSION        versionCode APP_VERSION_CODE        versionName APP_VERSION_NAME        //是否禁用外卖模块        buildConfigField "boolean", "DIABLE_TAKEAWAY", "true"        //bugtags app key信息        buildConfigField "String", "BUGTAGS_APP_KEY", "/"${bugtagsConfig.BUGTAGS_APP_KEY}/""        ndk {            // 设置支持的 SO 库构架            abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64', 'mips', 'mips64'        }    }    signingConfigs {        debug {            storeFile file("../readme/keystore/debug.keystore")        }        release {            storeFile file('../readme/keystore/releasekey.jks')            storePassWord "123456"            keyAlias "demo"            keyPassword "123456"        }    }    buildTypes {        debug {            signingConfig signingConfigs.debug        }        release {            minifyEnabled false            signingConfig signingConfigs.release            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'            applicationVariants.all { variant ->                variant.outputs.each { output ->                    def outputFile = output.outputFile                    if (outputFile != null && outputFile.name.endsWith('.apk')) {                        // 输出apk名称为release_v1.0_2015-01-15.apk                        def fileName = "release_v${defaultConfig.versionName}_${releaseTime()}.apk"                        output.outputFile = new File(outputFile.parent, fileName)                    }                }            }        }    }    lintOptions {        checkReleaseBuilds false        // Or, if you prefer, you can continue to check for errors in release builds,        // but continue the build even when errors are found:        abortOnError false    }}def releaseTime() {    return new Date().format("yyyy-MM-dd-hh-mm", TimeZone.getDefault())}//应用 Bugtags 插件apply plugin: 'com.bugtags.library.plugin'//Bugtags 插件配置bugtags {    //自动上传符号表功能配置,如果需要根据 build varint 配置,请参考帮助中心->符号表->Android 符号表->配置自动上传符号表    appKey bugtagsConfig.BUGTAGS_APP_KEY  //这里是你的 appKey    appSecret bugtagsConfig.BUGTAGS_APP_SECRET    //这里是你的 appSecret,管理员在设置页可以查看    mappingUploadEnabled true}dependencies {    apt 'org.parceler:parceler:1.1.6'    compile fileTree(include: ['*.jar'], dir: 'libs')    compile project(':lib')    compile project(':thirdsdk:baidumaPSDk')    compile project(':thirdsdk:sharesdk')    compile project(':thirdsdk:wechatpay')    compile 'com.aurelhubert:ahbottomnavigation:2.0.4'    compile 'org.parceler:parceler-api:1.1.6'    compile 'com.facebook.fresco:fresco:1.1.0'    compile 'net.cachapa.expandablelayout:expandablelayout:2.8'    compile 'com.bugtags.library:bugtags-lib:latest.integration'}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表