因此,要更改 gradle android 中生成的 APK 文件名,我可以执行以下操作:
So to change the generated APK filename inside gradle android I could do something like:
applicationVariants.output.all {
outputFileName = "the_file_name_that_i_want.apk"
}
生成的 App Bundle 文件有类似的东西吗?如何更改生成的 App Bundle 文件名?
Is there a similar thing for the generated App Bundle file? How can I change the generated App Bundle filename?
作为 Martin Zeitlers 回答的更通用方式以下将监听添加的任务,然后为添加的任何 bundle*
任务插入重命名任务.
As a more generic way to Martin Zeitlers answer the following will listen for added tasks, then insert rename tasks for any bundle*
task that gets added.
只需将其添加到 build.gradle
文件的底部即可.
Just add it to the bottom of your build.gradle
file.
注意:它会添加不必要的任务,但这些任务将被跳过,因为它们与任何文件夹都不匹配.例如<代码>>任务 :app:renameBundleDevelopmentDebugResourcesAab NO-SOURCE
Note: It will add more tasks than necessary, but those tasks will be skipped since they don't match any folder. e.g.
> Task :app:renameBundleDevelopmentDebugResourcesAab NO-SOURCE
tasks.whenTaskAdded { task ->
if (task.name.startsWith("bundle")) {
def renameTaskName = "rename${task.name.capitalize()}Aab"
def flavor = task.name.substring("bundle".length()).uncapitalize()
tasks.create(renameTaskName, Copy) {
def path = "${buildDir}/outputs/bundle/${flavor}/"
from(path)
include "app.aab"
destinationDir file("${buildDir}/outputs/renamedBundle/")
rename "app.aab", "${flavor}.aab"
}
task.finalizedBy(renameTaskName)
}
}
这篇关于如何使用 Gradle 更改 App Bundle 的生成文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!