android - 如何重命名 androidTest.apk 的 outputFileName?
问题描述
在互联网上搜索 2 天后,我找不到重命名 android-test.apk 的输出文件名(用于检测测试)的方法。我正在使用 assembleAndroidTest 和 assembleDebug 构建调试和检测测试 apk。
对于调试版本,我设法更改名称并添加版本,但我无法为 androidTest.apk 做到这一点。如何为测试 apk 添加相同的版本和其他名称?这是我的 build.gradle (模块)
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
project.archivesBaseName = "Automator"
defaultConfig {
applicationId "com.xxx.automator"
minSdkVersion 18
targetSdkVersion 29
versionCode 1
versionName "1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
android.applicationVariants.all { variant ->
variant.outputs.all {
def appName = "Automator"
outputFileName = appName + "-${variant.versionName}.apk"
}
}
}
}
}
解决方案
将此代码添加到您的应用程序build.gradle
:
android {
// Make custom APK name for test builds
testVariants.all { testVariant ->
testVariant.outputs.all { output ->
outputFileName = "CustomNameTest.apk"
}
}
}
推荐阅读
- javascript - ES6:如何使用 getter 和方法更新类中的属性
- excel - 从同一张表中插入空单元格值
- docker - 使用 Tensorflow 服务的 OpenFaaS 服务模型
- c# - WPF this.NavigationService.Navigate
- spring-boot-test - SpringBootTest 集成测试不适用于多个(@SpringBootApplication)
- python - 有没有办法在 VS Code 中引用 Python 项目?
- angular - 以编程方式创建 Angular 分层注入器
- linux - 我在 /usr/local/bin 中安装了 gcc 为什么 linux 找不到它
- c# - C#如何对datagridview中的数据求和
- python - Pywintauto findbestmatch 替代方案