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.
Try to update kotlin version in build.gradle.
ext.kotlin_version = '1.3.72'
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With