Gradle 14.4 Fails to Build - Gradle DSL method not

2019-04-18 01:16发布

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.

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-04-18 01:42

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.

查看更多
登录 后发表回答