jobin
jobin

Reputation: 1517

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

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.

Upvotes: 11

Views: 30226

Answers (4)

bulb
bulb

Reputation: 178

For me it turned out to be the following lione in the build.gradel

'classpath 'com.android.tools.build:gradle:8.5.1' It used to be 'classpath 'com.android.tools.build:gradle:3.3.2'

Upvotes: 7

Hayden Lee
Hayden Lee

Reputation: 161

Try to update kotlin version in build.gradle.

ext.kotlin_version = '1.3.72'

Upvotes: 16

David Miguel
David Miguel

Reputation: 14420

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"

Upvotes: 7

Amit
Amit

Reputation: 2715

Eventhough the answer is late but might help someone. Below worked for me.

Configure Kotin again in Android Studio → Preferences… →Plugins → Browse Repository → type “Kotlin” in search box → install/update.

Then restart the Android Studio and repeat the steps from scratch Android Studio → Tools → "Configure Kotlin in Project"

Upvotes: 1

Related Questions