Gradle 14.4 无法构建 - Gradle DSL 方法未找到“packageName()" [英] Gradle 14.4 Fails to Build - Gradle DSL method not found 'packageName()'

查看:47
本文介绍了Gradle 14.4 无法构建 - Gradle DSL 方法未找到“packageName()"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 productFlavors 并尝试根据风味更改 packageName:

productFlavors {风味 1 {包名com.mypackagename.one"}风味2{包名com.mypackagename.two"}}

这一直很好,直到我更新到 Gradle 0.14.4,现在它失败并显示以下消息:

Error:(21, 0) Gradle DSL 方法未找到:'packageName()'可能的原因:项目MyProject"可能正在使用不包含该方法的 Gradle 版本.<a href="open.wrapper.file">打开 Gradle 包装文件</a>构建文件可能缺少 Gradle 插件.<a href="apply.gradle.plugin">应用 Gradle 插件</a>

  1. 如何解决此问题,同时保留更改我的口味的包名称的能力?

  2. 如果这仅仅是因为方法名称发生了变化,我应该去哪里了解这些变化?我似乎找不到相关的变更日志,或解释如何执行此操作的更新文档.

解决方案

如何解决此问题,同时保留更改我的口味的 packageNames 的能力?

将它们更改为 applicationId:

productFlavors {风味 1 {applicationId "com.mypackagename.one"}风味2{applicationId "com.mypackagename.two"}}

<块引用>

我该去哪里了解这些变化?

目前,转到工具站点上的文档.

I'm using productFlavors and attempting to change the packageName depending on the flavor:

productFlavors {
    flavor1 {
        packageName "com.mypackagename.one"
    }
    flavor2 {
        packageName "com.mypackagename.two"
    }
}

This was working fine until I updated to Gradle 0.14.4, now it fails with the following message:

Error:(21, 0) Gradle DSL method not found: 'packageName()'

Possible causes:

The project 'MyProject' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a>

The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a>

  1. How can I resolve this issue, whilst retaining the ability to change the packageNames for my flavors?

  2. If this is simply because the method name has changed, where do I go to find out about these changes? I can't seem to find the associated changelog, or an updated doc explaining how to do this.

解决方案

How can I resolve this issue, whilst retaining the ability to change the packageNames for my flavors?

Change them to applicationId:

productFlavors {
    flavor1 {
        applicationId "com.mypackagename.one"
    }
    flavor2 {
        applicationId "com.mypackagename.two"
    }
}

where do I go to find out about these changes?

At the moment, go to the documentation on the tools site.

这篇关于Gradle 14.4 无法构建 - Gradle DSL 方法未找到“packageName()"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆