不支持的方法:AndroidArtifact.getBuildConfigFields()

7

我刚刚升级到了Android Studio 4.0并尝试构建我的项目。我不断收到以下错误信息:

Unsupported method: AndroidArtifact.getBuildConfigFields().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.

我已经在使用最新版本的Gradle和Gradle插件。
Gradle版本:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-milestone-1-all.zip

Gradle插件工具版本:

classpath 'com.android.tools.build:gradle:4.1.0-alpha10'

希望能提供任何针对该问题的解决方案或修复方法。谢谢您提前的帮助。

2个回答

6

使用 Android Studio 4.1 预览版 或 classpath 'com.android.tools.build:gradle:4.0.0'


2
这通常是由于您的Android Studio版本与Android Gradle插件不匹配造成的。您可以在首次打开项目时的项目选择窗口中找到Android Studio的版本(或在Mac上的“Android Studio > 关于Android Studio”及其他平台上的类似位置)。例如,您可能正在使用Android Studio 4.0.1。您可以在顶级build.gradle文件中找到您项目的Android Gradle插件版本。您应该能够找到以下类似内容:
buildscript {
    [...]
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        [...]
    }
    [...]
}

你需要确保这两个版本号匹配(在这种情况下它们是匹配的)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接