gpt4 book ai didi

android - gradle 实验性插件无法识别 android.applicationVariants.all

转载 作者:行者123 更新时间:2023-11-30 01:19:27 30 4
gpt4 key购买 nike

我最近将一个项目从gradle 2.1.0迁移到了gradle experimental plugin 0.7.0

在我的 2.1.0 脚本中,我有根据特定命名约定重命名 APK 的脚本。项目名称,后跟版本、日期时间。

新的 gradle experimental 插件似乎不再识别这个脚本了。有人可以帮忙吗?

gradle 实验性插件无法识别的脚本如下。

android.applicationVariants.all { variant ->
def appName
//Check if an applicationName property is supplied; if not use the name of the parent project.
if (project.hasProperty("applicationName")) {
appName = applicationName
} else {
appName = parent.name
}

variant.outputs.each { output ->
def newApkName
//If there's no ZipAlign task it means that our artifact will be unaligned and we need to mark it as such.
if (output.zipAlign) {
newApkName = "${appName}-${variant.versionName}.apk"
} else {
newApkName = "${appName}-${variant.versionName}-unaligned.apk"
}
output.outputFile = new File(output.outputFile.parent, newApkName.replace(".apk", "-" + getDateTime() + ".apk"))
}
}

import java.text.DateFormat
import java.text.SimpleDateFormat

def getDateTime() {
DateFormat df = new SimpleDateFormat("YYYY-MM-dd");

return df.format(new Date());
}

错误是

Error:FAILURE: Build failed with an exception.

* Where:
Script '/Users/vp/newconstruction/android-vpn/artifacts.gradle' line: 1

* What went wrong:
A problem occurred evaluating script.
> Could not find property 'android' on project ':main'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

最佳答案

经过一番挣扎后,我想在没有太多选择的情况下回答我自己的问题。

从gradle experimental plugin的官方文档可以看出,该插件还处于早期开发阶段。实验性插件的很多功能都不起作用。

http://tools.android.com/tech-docs/new-build-system/gradle-experimental

关于android - gradle 实验性插件无法识别 android.applicationVariants.all,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37349048/

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