Get IntelliJ Kotlin plugin and gradle to match up

2019-07-08 02:37发布

问题:

I'm trying IntelliJ 16, early access version, but my project won't compile with:

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. 

Presumably the Gradle and IntelliJ versions of Kotlin need to match up, but the installed Kotlin plugin is: 1.0.0-rc-1007-IJ143-11

I don't see this in any public repository. The latest one I have declared in the gradle project is:

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

. . can IntelliJ 16 be used with Kotlin and Gradle?

回答1:

In short, Kotlin IDEA plugin RC (1.0.0-rc-1007, 1017, 1025) is incompatible with Beta libraries, and RC libraries builds are not on Maven Central yet.

To use them, you have to add the EAP repository:

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

to both buildscript and the project part.

Also, your kotlin_version is incorrect, it shouldn't have -IJ143-11 part. Use 1.0.0-rc-1025.

The other solution is to rollback Kotlin plugin to Beta version, which involves deleting it (plugins subfolder of IDEA installation, as it is preinstalled in EAP 16) and installing the Beta again from ZIP distribution.

To learn more about EAP builds, please refer to this topic.


UPD:

The RC has been released along with the artifacts.