29

I updated my android studio to 2.2.Now when I open and run previous project I got error UnsupportedMethodException.

Unsupported method: AndroidProject.getPluginGeneration().
             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

.

Vini.g.fer
  • 11,639
  • 16
  • 61
  • 90
Gurjit Singh
  • 1,060
  • 2
  • 13
  • 16

5 Answers5

52

Here are some solutions for your problem. Disabling Instant run should be enough

Gradle version:

Go to your build.gradle file and change gradle-plugin version to:

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.0'
}

Instant Run

It is caused by Android Studio checking availability of the Instant Run feature.

Fix it by disabling Instant Run. Go to:

File -> Settings -> Build, Execution, Deployment -> Instant Run.

and uncheck all positions

Using android-apt plugin

This problem may be caused also by using this plugin.

I suppose for this example that you're using Butterknife library.....

NOTE: If you are using the new Jack compiler with version 2.2.0 or newer, you do not need the 'android-apt' plugin and can instead replace apt with annotationProcessor when declaring the compiler dependency.

Go to your build.gradle file and remove:

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

Then go to your app/build.gradle file and remove:

apply plugin: 'android-apt'

Then in the same file, replace existing:

apt 'com.jakewharton:butterknife-compiler:8.4.0'

with

annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'

It should work now

chancyWu
  • 14,073
  • 11
  • 62
  • 81
piotrek1543
  • 19,130
  • 7
  • 81
  • 94
  • 2
    Hi i could not find File -> Settings -> Build, Execution, Deployment -> Instant Run. Instant Run is not visible and im using android studio 2.2.2 on mac – Jono Dec 13 '16 at 12:33
  • 2
    @jonney on mac, it's Android Studio -> Preferences -> Build, Execution, Deployment -> Instant Run – xaphod Jan 10 '17 at 18:07
  • Disabling Instant Run does not make this error go away. – IgorGanapolsky Jun 22 '17 at 14:49
  • For me there solutions didn't work. What did work was to use version 22.0.0 for the appcompat-v7 and support-v4 libraries (in "app/build.gradle") and then click on the link suggested when the error is displayed, which is saying something about importing a Google Maven library/project. – Marcell Jul 07 '19 at 19:54
3

You are trying to import a gradle project built with a version not suppoted in your ide(Android Studio), try to rebuild your project with a compatible version from the command line first:

gradle wrapper --gradle-version 3.0

(3.0 is just an example, try to find out what version needs your IDE).

After this step the import process should be ok

colo
  • 152
  • 4
2

Update Gradle version to a higher version for me it starts working when I updated it to 2.10

Mohit
  • 885
  • 9
  • 7
1

As per some of the above, go to File -> Project structure, in the first two fields I entered the most recent Gradle version and Android Plugin Version and click OK, and then wait. The whole process may take half an hour, but keep clicking the blue hyperlinks and they will get it done for you!

Brian Fleming
  • 63
  • 1
  • 6
0

Through each modification of this trouble shoot (see below)

YOU CAN EITHER sync by doing File->Sync Project with Gradle Files OR

File -> INVALIDATE CACHES/RESTART enter image description here

My Android Studio version My Android Studio version

This is the TOP-LEVEL build.gradle (NOT THE INDIVIDUAL FOR YOUR PROJECT ""...\YOUR-PROJECT\build.gradle"" This is the TOP-LEVEL build.gradle (NOT THE INDIVIDUAL FOR YOUR PROJECT)

This is my INDIVIDUAL project build.gradle "...\YOUR-PROJECT\app\build.gradle" This is my INDIVIDUAL project build.gradle

This is my "...\YOUR-PROJECT\gradle\wrapper\gradle-wrapper.properties" file gradle-wrapper file

This is the error This is the error

As per the answer above "Brian Fleming" As per the answer above "Brian Fleming"

Browse through you should see a relation with the TOP LEVEL gradle file and the gradle-wrapper file Browse through you should see a relation with the gradle files

NOTE

  • the ...\YOUR-PROJECT\gradle\wrapper\graddle-wrapper.properties file and
  • the......\YOUR-PROJECT\build.gradle file
  • will get edited by using the Android Studio GUI by using File->Project Structure

It seems to be in the "app\build.gradle", THE INDIVIDUAL gradle file This is the Warning I found

It says"Dependencies: com.android.support:appcompat-v7:25.2.0: Obsolete dependency configuration found: compile[Update compile to implementation]"

Go through each warning and click **"[Update compile... in blue]" this should update each of the "compile" to "implementation"

You can also edit the file itself on notepad, I opted for doing it in the GUI Go through each warning**

Sync Project with Gradle Files Sync Project with Gradle Files

Next thing you know you will get this error.... "Gradle - Error Could not find method implementation() for arguments..."

  • This is because in my case the project I was working with was old, and had the gradle 2.0.0 in the TOP LEVEL YOUR-PROJECT/build.gradle

  • And 2.10 for the "...\YOUR-PROJECT\gradle\wrapper\gradle-wrapper.properties"

  • Also the INDIVIDUAL "...\YOUR-PROJECT\app\build.gradle" had the deprecated "compile" instead of the currently used "implementation"

  • Therefore when I substituted for the current "implementation" the gradle version for both gradle TOP-LEVEL and gradle-wrapper.properties files needed to be updated as well.

  • I updated them to TOP-LEVEL to 3.1.4 AND gradle-wrapper.properties to 4.4

SEE HERE UPDATING THE GRADLE FILES

YOU MAY ALSO GET THIS ERROR something in the lines of "could not find file in jcenter"

Here Adding google repository

I only added it in the "buildscript", NOT in the "allprojects", I really don't know if in your case is different. But it worked for me (I only take baby steps and if not progress with more changes)

THIS MAY NOT APPLY TO YOU but check below if get this error

Error for SDK tool version too old This error was produced because I had new grade files BUT my buildToolVersion in the INDIVIDUAL gradle file YOUR-PROJECT/app/build.gradle was below the minimum supported for those new gradel files. And the error itself tells you to change it to "27.03" (do it)

YOU CAN EITHER sync by doing File->Sync Project with Gradle Files OR File -> INVALIDATE CACHES/RESTART (This is the one I have been using through out this troubleshooting)