gpt4 book ai didi

android - 如何在 gradle 4 上获取我的应用程序文件夹?

转载 作者:行者123 更新时间:2023-11-29 19:06:36 26 4
gpt4 key购买 nike

我曾经这样做来命名我的 apk:

outputFileName = new File(output.outputFile.parent, "apk/myapk.apk")

现在它提示 output.outputFile.parent。那么解决这个问题的正确方法是什么?

我遵循了迁移指南中的步骤,但将 apk 放在其他目录中。我想要它在 app/apk/

谢谢。

最佳答案

来自 Migration guide

android.applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = "${variant.dirName}" +"${variant.name}-${variant.versionName}.apk"
println (output.outputFile.parent)
}
}

Apk 输出目录是 /app/build/outputs/apk/debug/

有关迁移指南的更多信息

However, more complicated tasks that involve accessing outputFile objects no longer work. That's because variant-specific tasks are no longer created during the configuration stage. This results in the plugin not knowing all of its outputs up front, but it also means faster configuration times.

编辑app/apk中获取.apkgradle file

中做
def path = "../../../../../app/apk/"
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = new File( path + "${variant.dirName}" +"${variant.name}-${variant.versionName}.apk")
println (output.outputFile.parent)
}

Apk 输出目录是 /app/apk/

关于android - 如何在 gradle 4 上获取我的应用程序文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46985217/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com