Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsupported method: AndroidArtifact.getBuildConfigFields()

I have just updated to Android Studio 4.0 and trying to build my project. I keep on getting the below error

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.

I am already using the latest version of Gradle and Gradle Plugin

Gradle version:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-milestone-1-all.zip

Gradle plugin tools version:

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

Any solution or fix for this problem would be helpful. Thanks in advance.

like image 284
GOVIND DIXIT Avatar asked Jun 06 '20 15:06

GOVIND DIXIT


2 Answers

Use Android studio 4.1 preview or classpath 'com.android.tools.build:gradle:4.0.0'

like image 159
Yuchuan Gu Avatar answered Sep 29 '22 07:09

Yuchuan Gu


This is usually due to a mismatch between your Android Studio versions and the Android Gradle plugin.

You can find the version of Android Studio on the project selection window when you first open it (or in "Android Studio > About Android Studio" on Mac, and similar location on other platforms). For example, you might be using Android Studio 4.0.1.

You can find the Android Gradle plugin version for your project in the top-level build.gradle file.

You should find something like the following:

buildscript {
    [...]
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        [...]
    }
    [...]
}

You need to make sure that the two version numbers match (in this case they do).

like image 21
Flavio Avatar answered Sep 29 '22 05:09

Flavio