【问题标题】:Android gradle unable to find method 'org.grade.api.internal.file.DefaultSourceDirectorySet'Android gradle 找不到方法“org.grade.api.internal.file.DefaultSourceDirectorySet”
【发布时间】:2018-01-01 08:54:17
【问题描述】:

我尝试将一个 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.

【问题讨论】:

  • 你用的是什么版本的gradle?
  • 类路径'com.android.tools.build:gradle:3.0.1'
  • 尝试无效缓存/重启
  • 现在试试....
  • 还是同样的问题。说 kotlin 没有配置

标签: android gradle


【解决方案1】:

尝试在 build.gradle 中更新 kotlin 版本。

ext.kotlin_version = '1.3.72'

【讨论】:

    【解决方案2】:

    即使答案很晚,但可能会对某人有所帮助。下面对我有用。

    在 Android Studio 中再次配置 Kotin → Preferences... →Plugins → Browse Repository → 在搜索框中输入“Kotlin” → 安装/更新。

    然后重启 Android Studio 并从头开始重复步骤 Android Studio → Tools → "Configure Kotlin in Project"

    【讨论】:

      【解决方案3】:

      就我而言,我收到错误是因为 Kotlin Gradle 插件的版本与 Kotlin Android Studio 插件中配置的版本不同。

      更新 Kotlin Gradle 插件的版本以匹配另一个解决了该问题。

      你可以在Preferences / Languages &amp; Frameworks / Kotlin Updates看到Kotlin Android Studio插件的版本

      它应该和你的一样:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-04-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-28
        相关资源
        最近更新 更多