Gradle Sync Failed: Unable to Find Method

Gradle sync failed: Unable to find method

I fixed the error by changing the following things.

  1. Open the file under your-app-project\your-app-name\gradle\wrapper\gradle-wrapper.properties
  2. replace the old URL path by this one:
    distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip

  3. Rename the folder name from "...\1.12" to your-app-project\your-app-name.gradle\2.10

  4. Change the classpath of your-app-project\your-app-name\build.gradle to
    classpath 'com.android.tools.build:gradle:2.1.2'

  5. Replace runProguard of your-app-project\your-app-name\app\build.gradle by minifyEnabled

  6. Click Retry on the error reminder or Reopen your Android Studio and project.

I am using the latest versions of Android Studio and Gradle.

Gradle sync failed: Unable to find method after update to Gradle 4.0.0

This may be because of any 3rd party Gradle plugin not supporting the new Tasks API. In my case it was because of greendao Gradle plugin.

If you are using greendao update it to the latest version 3.3.0:

classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0'

Or else you will have to find the plugin that is causing the issue.

Gradle failed to restore: Unable to find method 'org.gradle.api.file.ProjectLayout.directoryProperty

The issue was that I upgraded to Android Studio v4, and seem like the download project was created using Android Studio v3.
After go to

File/ Project Structure.../

And change the Android Gradle Plugin Version from 3.3.1 to 4.0.1 and now project loaded fine.
Not sure why Android Studio v4 is not backward compatible with Gradle version 3.
Sample Image

Gradle build fails: Unable to find method 'org.gradle.api.tasks.testing.Test.getTestClassesDirs()Lorg/gradle/api/file/FileCollection;'

I had to change the distributionUrl in the gradle-wrapper.properties to distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip to get the build running again. This seems to be a similar problem Gradle sync failed: Unable to find method.

Gradle project sync failed after update - Unable to find method 'com.google.common.collect.ImmutableSet.toImmutableSet()Ljava/util/stream/Collector;'

I suspect that this has to do with conflicts in Guava depending on the
Gradle version you use and the Guava version your dependencies use.

The function toImmutableList was added in Guava 21 (Guava 20).

I suggest you try downgrading the project's gradle version to 3.3 or so and try again.



Related Topics



Leave a reply



Submit