我尝试将一个 java 类转换为 Kotlin,除了出现以下错误外,它工作正常。我尝试重新下载所有依赖项,如以下建议的,但无济于事。请帮助我解决此错误。
错误:
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.
Run Code Online (Sandbox Code Playgroud)
小智 7
尝试在 build.gradle 中更新 kotlin 版本。
ext.kotlin_version = '1.3.72'
Run Code Online (Sandbox Code Playgroud)
就我而言,我收到错误是因为 Kotlin Gradle 插件的版本与 Kotlin Android Studio 插件中配置的版本不同。
更新 Kotlin Gradle 插件的版本以匹配另一个版本解决了这个问题。
您可以在以下位置看到 Kotlin Android Studio 插件的版本: Preferences / Languages & Frameworks / Kotlin Updates
它应该与您相同:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
尽管答案迟到了,但可能会对某人有所帮助。下面为我工作。
\n\n在 Android Studio 中再次配置 Kotin \xe2\x86\x92 Preferences\xe2\x80\xa6 \xe2\x86\x92Plugins \xe2\x86\x92 Browse Repository \xe2\x86\x92 type \xe2\x80\x9cKotlin\xe2\x80搜索框中的 \x9d \xe2\x86\x92 安装/更新。
\n\n然后重新启动Android Studio,从头开始重复步骤Android Studio \xe2\x86\x92 Tools \xe2\x86\x92“在项目中配置Kotlin”
\n 归档时间: |
|
查看次数: |
8048 次 |
最近记录: |