2
votes

I generate a skeleton kotlin application via gradle init --dsl kotlin -> load the project into intellij and I receive following error. screenshot attached.

Type mismatch : inferred type is kotlin.String but java.lang.String was expected.

I have tried various steps of invalidating caches/restart. removing .gradle, .idea, ~/.gradle etc. refreshing gradle projects, stopping gradle daemon. refreshing intellij project (Removing ~/.intellijIDea../system dir). However, none have helped. please tell me what else can I do ?

as I said, I generated project via gradle init --dsl kotlin. gradle version 5.2.1, kotlin plugin version 1.3.20. all latest. intellij idea is at 2018.3 version. For starters, build.gradle.kts is as follows:

plugins {
    // Apply the Kotlin JVM plugin to add support for Kotlin on the JVM.
    id("org.jetbrains.kotlin.jvm").version("1.3.20")

    // Apply the application plugin to add support for building a CLI application.
    application
}

repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    // Use the Kotlin JDK 8 standard library.
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

    // Use the Kotlin test library.
    testImplementation("org.jetbrains.kotlin:kotlin-test")

    // Use the Kotlin JUnit integration.
    testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}

application {
    // Define the main class for the application.
    mainClassName = "info.XXX.YYY"
}

enter image description here

1

1 Answers

5
votes

on stack overflow, I landed on a link where it informed to use oracle jdk instead of openjdk. installed oracle jdk -> invalidate cache/restart, did it for me.