在build.gradle中根据自己的需求配置, releaseTime是我自已写的一个获取时间的函数,可以把当前打包的时候追加到文件名中,也可以判断variant.buildType.name字段的值来生成debug还是release  拼接示例:    output.outputFileName = "Remote${android.defaultConfig.versionName}_${releaseTime()}_debug_nosign.apk"    获取量值使用${字段或函数名},其他字符串可直接写,随意拼接,使用“”把总字符串括起来即可。apply plugin: 'com.android.application'def releaseTime(){    return new Date().format("MMddhhmmss",TimeZone.getTimeZone("UTC"))}android {    compileSdkVersion 28    defaultConfig {        applicationId "xxx.xxxxxx.xx"        minSdkVersion 19        //noinspection ExpiredTargetSdkVersion        targetSdkVersion 19        versionCode 1        versionName "1.0"    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'        }    }    compileOptions {        sourceCompatibility JavaVersion.VERSION_1_8        targetCompatibility JavaVersion.VERSION_1_8    }    sourceSets {        main {            jniLibs.srcDirs = ['libs']            java.srcDirs = ['src/main/java','src/main/aidl']        }    }    applicationVariants.all {variant ->        variant.outputs.all {output ->            if (variant.buildType.name == "debug") {                output.outputFileName = "Remote${android.defaultConfig.versionName}_${releaseTime()}_debug_nosign.apk"            } else if (variant.buildType.name == "release") {                output.outputFileName = "Remote${android.defaultConfig.versionName}_${releaseTime()}_release_nosign.apk"            }        }    }}dependencies {    implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')    testImplementation 'junit:junit:4.12'    androidTestImplementation 'com.android.support.test:runner:1.0.2'    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'    implementation 'com.google.code.gson:gson:2.8.5'    implementation 'com.android.support:appcompat-v7:28.0.0'}

 

更多相关文章

  1. Android的国际化与本地化
  2. TextView组件改变部分文字的颜色
  3. Github-Client(ANDROID)开源之旅(二) ------ 浅析ActionBarSherkLoc
  4. Android小技巧总结1
  5. Android通过HttpURLConnection获取JSON并进行UI更新
  6. Android.text.TextUtils类
  7. 【Android开发】完善搜索功能-添加最近查询字段
  8. Android控件的一般属性
  9. Value xxx of type org.json.JSONObject cannot be converted to

随机推荐

  1. Android(安卓)- under the hood
  2. Android(安卓)实现发送短信demo
  3. android上传文件到服务器
  4. Android官方文档翻译 三 1.1Creating an
  5. Android学习笔记(7)————Android中的
  6. Android多指触摸
  7. android avoiding-memory-leaks
  8. android 柱状图(带动画的)
  9. android电量状态获取
  10. android > SMS 短信数据库访问