Unsupported method: AndroidProject.getVariantNames() in Android Studio 3.4 –

Development issue/problem:

I just updated Android Studio 3.4 (Canary 5). I then opened my existing project (which worked well on the Android Studio 3.3 beta) and I got this error:

ERROR: Unsupported method : AndroidProject.getVariantNames().
The version of Gradle you connect to does not support this method.
You can change/update the target version of Gradle you are connecting to to solve the problem.
You can also ignore this exception and read other information from the template.

Full cleaning and recovery, Invalid cache and restart, Project reimport does not work.

Get ready for graduation. Properties :

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/mounting
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/mounting
distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip

build.gradle (project level) :

Dependencies {
classpath ‘com.android.tools.build:gradle:3.1.3’
}

About Android Studio

Android Studio 3.4 Canary 5
build #AI-183.4284.36.34.5141831, built on 20. November 2018
JRE : 1.8.0_152-release-1248-b01 amd64
FMV : 64-bit OpenJDK VM server from JetBrains s.r.o.
Linux 4.15.0-39 generic

How do we solve this problem?

How can I solve this problem?

Solution 1:

You must disable this setting in Android Studio:

File > Preferences (or preferences for previous versions) > Experimental > Only active option for synchronization.

Solution 2:

I finally figured out how to make it work again.

Try switching to distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip in the gradle-wrapper properties.

And classpath ‘com.android.tools.build:gradle:3.2.1’ in build.gradle (project level).

Solution 3:

This problem occurred after the installation of the new Android Studio 3.3.

I installed Android 8.1 (Oreo) via Tools -> SDK Manager or File -> Settings -> Appearance and Behavior -> System Settings -> Android SDK and managed to synchronize and build the project.

Solution 4:

The same error message after upgrading to Android Studio 3.3 and reloading an old project with a previous version of Gradle. I corrected my project by modifying the following line in the gradle.build file that exists at project level

Dependencies {
classpath ‘com.android.tools.build:gradle:3.3.0’
}

I also removed some old SDK’s and had to install the SDK at project level in Open Module Settings.

After these two changes, the messages have changed and some references to self-correction have been included, which my project has done as usual.

ERROR: The minimum supported version of Gradle is 4.10.1. Current version
4.4.
Correct the settings of the Gradle project.
Correct packaging and re-importation of projects

Solution No 5:

Another answer solved the problem in my case,
I discovered it was due to the lack of a license agreement.

To remedy this, you must do the following

on Linux and Ox :

$ANDROID_HOME/tools/bin/disk manager – Objective

or Windows :

> C:UserserikAppDataLocalAndroidSdktoolsbinsdkmanager.bat licenses

and accept all license agreements.

Solution No 6:

This happens when you have installed a new version of Android Studio, for example 3.x.x.
You can correct this error by simply adding the following line to your build.gradle file.

dependencies{klasspath ‘com.android.tools.build:gradle:3.3.0’ }

Solution No 7:

There are two different things: the distribution of the URL and the plugin version.

The plugin version is specified in the build.gradle file at project level as classpath ‘com.android.tools.build:gradle:3.2.1’ or ‘com.android.tools.build:gradle:3.3.1’.

And distributionUrl points to GradleWrapper, which can be found at (gradle-wrapper.properties).

If you follow this link, you will see the connection between the two.

In April 2019 the latest version of the plugin is 3.4.0
, and the latest distribution is 5.1.1.

So, in the build.gradle file of your project level

Dependencies {
classpath ‘com.android.tools.build:gradle:3.4.0’.

// NOTE : Do not place your application dependencies here, they belong to
// in separate build.gradle
} module files.

and a lot of diplomas. Do the functions:-

distributionUrl=https://services.gradle.org/distributions/gradle-5.1.1-all.zip

Then synchronize it, and you’ll be fine.

Solution No 8:

Just check the Android Gradle plugin version notes and you will be able to match the available plugin version with the Gradle plugin version. An updated version of this table is available on this site.

In the file gradle-wrapper.properties you can change the required version of gradle as follows

distributionUrl = https://services.gradle.org/distributions/gradle-5.4.1-all.zip

In the build.gradle file, add the correct version of the gradle plugin as follows

Dependencies {
classpath ‘com.android.tools.build:gradle:3.5.2’
}

Good luck!

Related Tags: