Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android gradle unable to find method 'org.grade.api.internal.file.DefaultSourceDirectorySet'

Tags:

android

gradle

I tried to convert a java class to Kotlin, which worked Ok except I got the following error.I tried to re download all dependencies like suggessted in the below, but to no avail.Please help me with this error.

Error:

Error:(2, 0) Unable to find method 'org.gradle.api.internal.file.DefaultSourceDirectorySet.<init>(Ljava/lang/String;Lorg/gradle/api/internal/file/FileResolver;)V'.
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li><li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
like image 256
jobin Avatar asked Dec 03 '22 11:12

jobin


2 Answers

Try to update kotlin version in build.gradle.

ext.kotlin_version = '1.3.72'
like image 159
Hayden Lee Avatar answered May 17 '23 23:05

Hayden Lee


In my case, I was getting the error because the version of the Kotlin Gradle plugin was different from the one configured in the Kotlin Android Studio plugin.

Updating the version of the Kotlin Gradle plugin to match the other one solved the issue.

You can see the version of the Kotlin Android Studio plugin in: Preferences / Languages & Frameworks / Kotlin Updates

It should be the same you have in:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

like image 42
David Miguel Avatar answered May 18 '23 00:05

David Miguel