IntelliJ (using gradle): Can't find Kotlin plu

2019-02-19 04:59发布

问题:

I'm trying to build my project using gradle but it seems that it can't find my kotlin plugin, even though I did add it using "install plugin from disk".

This is the error I'm getting:

Could not resolve all dependencies for configuration ':classpath'. Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.0.0-release-1038. Searched in the following locations: https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.0.0-release-1038/kotlin-gradle-plugin-1.0.0-release-1038.pom https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.0.0-release-1038/kotlin-gradle-plugin-1.0.0-release-1038.jar

Can anyone help me with this? I'd really like to build my project.

回答1:

I can guess that you doesn't have repository in build.gradle, so please compare your build file with following, and then make "Gradle Refresh" in Idea.

buildscript {
  ext.kotlin_version = '<version to use>'
  repositories {
    mavenCentral()
    // or better:
    jcenter()
  }
  dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  }
}

apply plugin: "kotlin"

repositories {
  mavenCentral()
  // or better:
  jcenter()
}

dependencies {
  compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

Pay more attention to buildscript part of config: repositories here is necessary!

I got config from here, with my little refinements.