Android(安卓)studio配置输出的apk文件名
16lz
2021-01-26
在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'}
更多相关文章
- Android的国际化与本地化
- TextView组件改变部分文字的颜色
- Github-Client(ANDROID)开源之旅(二) ------ 浅析ActionBarSherkLoc
- Android小技巧总结1
- Android通过HttpURLConnection获取JSON并进行UI更新
- Android.text.TextUtils类
- 【Android开发】完善搜索功能-添加最近查询字段
- Android控件的一般属性
- Value xxx of type org.json.JSONObject cannot be converted to