Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I updated gradle to 4.0.0

classpath 'com.android.tools.build:gradle:4.0.0'

and the distributionUrl to:

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

after sync the prject I got:

Unable to find method 'org.gradle.api.tasks.TaskInputs.property(Ljava/lang/String;Ljava/lang/Object;)Lorg/gradle/api/tasks/TaskInputs;'.

I know, if I downgrade the version the project will sync properly. but is there some incompatibility somewhere ? if it's true why there is some updates ?

like image 456
Walid Avatar asked May 29 '20 05:05

Walid


2 Answers

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.

like image 94
rakex Avatar answered Oct 06 '22 06:10

rakex


Solution for the following error in Android Studio 4.0 while using Gradle Plugin 4.0.0 and Gradle version gradle-6.1.1-all.zip:

Error: Unable to find method 'org.gradle.api.tasks.TaskInputs.property(Ljava/lang/String;Ljava/lang/Object;)Lorg/gradle/api/tasks/TaskInputs;'.

Root-cause: The problem is being originated from the older version of GreenDao Library (earlier than 3.3.0) that does not support Gradle 6.0.0 and Gradle plugin earlier than 3.3.x

Solution: Collected from the release note of Latest build (GreenDao v3.3.0) following support has been added in the latest build: --- Support Android Gradle Plugin 3.3+ APIs. #942 --- Support Gradle 6.0. #1002

After updating the library to 3.3.0 in root build.gradle (project)

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

and in build.gradle module:

implementation "org.greenrobot:greendao:3.3.0"

the issue got resolved.

SPECIAL NOTE: Similar error can be thrown by any other libraries that do not support latest gradle plugin. To identify, which library is causing the problem, you can run:

./gradlew tasks --stacktrace
like image 33
Mohammad Arman Avatar answered Oct 06 '22 06:10

Mohammad Arman