Gradle sync failed: Unable to find method
I fixed the error by changing the following things.
- Open the file under your-app-project\your-app-name\gradle\wrapper\gradle-wrapper.properties
replace the old URL path by this one:
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zipRename the folder name from "...\1.12" to your-app-project\your-app-name.gradle\2.10
Change the classpath of your-app-project\your-app-name\build.gradle to
classpath 'com.android.tools.build:gradle:2.1.2'Replace runProguard of your-app-project\your-app-name\app\build.gradle by minifyEnabled
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.
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
Calculating the Angle Between a Line and the X-Axis
Java.Lang.Noclassdeffounderror: Com.Google.Ads.Adview
Android: How to Hide Actionbar on Certain Activities
Using Httpclient and Httppost in Android with Post Parameters
How to Adjust Microphone Sensitivity While Recording Audio in Android
Changing Openssl Library in Android App for Httpclient
When Onbindviewholder Is Called and How It Works
How to Avoid Unnecessary Firestore Reads with Cache
No Resource Identifier Found for Attribute 'Layout_Behavior' in Package
Override Context Menu Colors in Android
How to Combine One Android Studio Project into Another Android Studio Project
Version Control for One-Man Project Using Eclipse
Html/JavaScript Debugging in Javafx Webview
How to Pass an Arraylist to a Varargs Method Parameter
Runtime.Exec():Reboot in Android