nulldroid
nulldroid

Reputation: 1230

Getting weird bugs when trying to update to Kotlin 1.4.0. How to make it work with Gradle and IntelliJ IDEA 2020.2.1?

Kotlin 1.4.0 is stable now. Therefor, I wanted to update my multi module Android project to use it. I set IDEA to use Kotlin plugin 1.4.0-release-IJ2020.2-1 and in my buildSrc build.gradle.kts using Kotlin DSL, I'm loading Kotlin for the jvm like this:

plugins {
    kotlin("jvm") version "1.4.0"
}

My app level plugins block looks like this

plugins {
    id("com.android.application")
    id("com.google.gms.google-services")
    kotlin("android")
    kotlin("kapt")
    id("kotlin-android-extensions")
    id("androidx.navigation.safeargs.kotlin")
}

I have also added the Kotlin stdlib to my app level build.gradle.kts dependencies

implementation("org.jetbrains.kotlin:kotlin-stdlib:1.4.0")

When trying to build my project now, I get multiple Errors like the following:

'let((T) -> R): R' is only available since Kotlin 1.3.50 and cannot be used in Kotlin 1.3

I don't understand. How is gradle trying to use Kotlin 1.3 here? Any idea on how to fix this? Its working fine when using Kotlin v1.3.72 instead.

What I tried so far:

UPDATE Forgot to mention that I'm also getting the following warning. How is it unsupported when it is stable?

> Configure project :buildSrc
WARNING: Unsupported Kotlin plugin version.
The `embedded-kotlin` and `kotlin-dsl` plugins rely on features of Kotlin `1.3.72` that might work differently than in the requested version `1.4.0`.

Upvotes: 5

Views: 6514

Answers (1)

J. Buehler
J. Buehler

Reputation: 260

Maybe you should add the Kotlin standard lib to your dependencies explicitly?

dependencies {
    implementation(kotlin("stdlib"))
}

With Kotlin 1.4 it is no longer required it add this dependency. The plugin applies the Stdlib by default to the projects it is applied to.

From the Kotlin 1.4 release notes:

You no longer need to declare a dependency on the stdlib library in any Kotlin Gradle project, including a multiplatform one. The dependency is added by default.

The automatically added standard library will be the same version of the Kotlin Gradle plugin, since they have the same versioning.

Upvotes: 2

Related Questions