UnsupportedMethodException Android Studio 2.2

前端 未结 5 1879
梦如初夏
梦如初夏 2021-01-31 09:12

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

Unsupported method: AndroidProject.getPluginG         


        
相关标签:
5条回答
  • 2021-01-31 09:36

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

    0 讨论(0)
  • 2021-01-31 09:39

    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

    0 讨论(0)
  • 2021-01-31 09:39

    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!

    0 讨论(0)
  • 2021-01-31 09:44

    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

    My Android Studio version

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

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

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

    This is the error

    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

    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

    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 **

    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

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

    • There is 3 different repositories your build or gradle will get stuff from those are jcenter(), google() and mavenCentral() for more info go here: https://docs.gradle.org/current/userguide/declaring_repositories.html

    • In my case if you check my TOP LEVEL grade file the project only had jcenter(), so I just added google() in the repositories

    Here

    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

    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)

    0 讨论(0)
  • 2021-01-31 09:54

    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

    0 讨论(0)
提交回复
热议问题