【问题标题】:Get IntelliJ Kotlin plugin and gradle to match up获取 IntelliJ Kotlin 插件和 gradle 进行匹配
【发布时间】:2025-12-29 08:15:11
【问题描述】:

我正在尝试 IntelliJ 16,早期访问版本,但我的项目无法编译:

Error:(16, 17) Kotlin: Unresolved reference: substring
(note: this may be caused by the fact that some classes compiled with 
an incompatible version of Kotlin were found in the classpath. Such 
classes cannot be loaded properly by this version of Kotlin compiler. 

想必Kotlin的Gradle和IntelliJ版本需要匹配,但是安装的Kotlin插件是:1.0.0-rc-1007-IJ143-11

我在任何公共存储库中都没有看到这个。我在gradle项目中声明的最新的是:

buildscript {
    ext.kotlin_version = ' 1.0.0-rc-1007-IJ143-11'

。 . IntelliJ 16 可以与 Kotlin 和 Gradle 一起使用吗?

【问题讨论】:

    标签: java intellij-idea gradle kotlin


    【解决方案1】:

    简而言之,Kotlin IDEA 插件 RC(1.0.0-rc-100710171025)与 Beta 库不兼容,并且 RC 库构建尚未在 Maven Central 上。

    要使用它们,您必须添加 EAP 存储库:

    repositories {
        // ...
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap/' }
    }
    

    buildscript 和项目部分。

    另外,您的kotlin_version 不正确,它不应该有-IJ143-11 部分。使用1.0.0-rc-1025

    另一种解决方案是将 Kotlin 插件回滚到 Beta 版本,这涉及删除它(IDE​​A 安装的plugins 子文件夹,因为它已预安装在 EAP 16 中)并从 ZIP 分发中重新安装 Beta。

    要了解有关 EAP 构建的更多信息,请参阅this topic


    更新:

    RC 已与工件一起发布。

    【讨论】:

    • 我使用了第二个建议。当我升级 gradle 的 kotlin 以匹配 intellij 时,它抱怨一些依赖项(杰克逊的 Kotlin 模块)在旧 ABI 上。
    • 该库 @JasperBlues 有一个 EAP 构建,在 Kotlin Slack 聊天的 #eap 频道中,有关于私有 EAP 期间库发布和临时回购的细节。如果你在 Slack,kotlinlang.slack.com/archives/eap/p1454443147000351 如果没有添加 maven repo http://dl.bintray.com/jaysonminard/kohesive 并使用最匹配 2.5.5-RC-10252.6.5-RC-10252.7.0-RC-1025 的 jackson kotlin 模块
    • 谢谢@JaysonMinard,我会加入 Slack 频道。很乐意测试 EAP 版本。
    • 呃。 .那是一个社区 Slack 频道吗?如何加入?
    • RC 代表什么?