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

4

9

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.
Boric answered 1/1, 2018 at 8:54 Comment(7)
what version of gradle are you using ?Responsibility
classpath 'com.android.tools.build:gradle:3.0.1'Boric
Try Invalidate Caches/RestartResponsibility
trying it now....Boric
Still same problem.Says kotlin not configuredBoric
I tried to configurate kotlin.I get an alert dialog 'there anren't configurators available'Boric
Disable and reenable gradle plugin. Make some change in build.gradle file and syncResponsibility
T
16

Try to update kotlin version in build.gradle.

ext.kotlin_version = '1.3.72'
Tremayne answered 20/5, 2020 at 4:0 Comment(0)
C
7

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"

Cotinga answered 19/12, 2018 at 21:47 Comment(0)
S
1

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"

Skyscape answered 16/10, 2018 at 10:6 Comment(0)
B
0

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'

Bikol answered 30/7 at 21:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.