Cannot use Kotlin 1.7.10 - kotlin

I have a Kotlin project in IntelliJ IDEA (not targeting Android) that currently compiles fine with Kotlin 1.6.10. When I change to 1.7.10, I get the following errors:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'jwotd'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0.
Required by:
project :
> The consumer was configured to find a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally. However we cannot choose between the following variants of org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0:
- gradle70JavadocElements
- gradle70RuntimeElements
- gradle70SourcesElements
- javadocElements
- runtimeElements
- sourcesElements
All of them match the consumer attributes:
- Variant 'gradle70JavadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides javadocs but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'gradle70RuntimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0 declares a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Unmatched attributes:
- Provides a library but the consumer didn't ask for it
- Provides attribute 'org.gradle.jvm.environment' with value 'standard-jvm' but the consumer didn't ask for it
- Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but the consumer didn't ask for it
- Variant 'gradle70SourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides sources but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'javadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides javadocs but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides release status but the consumer didn't ask for it
- Variant 'runtimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0 declares a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Unmatched attributes:
- Provides a library but the consumer didn't ask for it
- Provides attribute 'org.gradle.jvm.environment' with value 'standard-jvm' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but the consumer didn't ask for it
- Variant 'sourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides sources but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides release status but the consumer didn't ask for it
The following variants were also considered but didn't match the requested attributes:
- Variant 'apiElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0 declares a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
- Variant 'gradle70ApiElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0 declares a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
My top-level build.gradle:
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
One of my project build.gradle (there are several projects, all similar):
apply plugin: 'org.jetbrains.kotlin.jvm'
sourceSets {
main {
java.srcDirs "src/java"
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
dependencies {
api project(':cjk')
implementation project(':kokuban')
implementation platform('org.jetbrains.kotlin:kotlin-bom')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.beust:klaxon:5.0.1'
implementation "com.oracle.database.xml:xmlparserv2:21.1.0.0"
}

Open your gradle/wrapper/gradle-wrapper.properties file and modify the gradle version to:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip

I had to manually upgrade gradle.
./gradlew wrapper --gradle-version 7.5.1
./gradlew --version
./gradlew build
After this, gradlew builds Kotlin 1.7.10 code, and it also builds successfully in IntelliJ IDEA. Interestingly though, the IntelliJ complains about unavailable features (definitely typed T & Any), but it can compile it and it seems to work.
Feels like IntelliJ IDEA CE does not officially support Kotlin 1.7.10 yet?

In my case, Just replace to
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
From
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'

https://kotlinlang.org/docs/gradle.html
When configuring your project, check the Kotlin Gradle plugin compatibility with available Gradle versions:
Kotlin 1.7.20 requires Gradle 6.7.1 as a minimum version. Kotlin 1.7.10 will do similarly.
Please check your Gradle version.

Invalidate Caches and Restart resolved my issue

This is how a freshly generated (by IDEA CE / gradle-7.4.2) build.gradle looks like
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.7.10'
}
group = 'org.example'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-test'
}
test {
useJUnitPlatform()
}
compileKotlin {
kotlinOptions.jvmTarget = '1.8'
}
compileTestKotlin {
kotlinOptions.jvmTarget = '1.8'
}

You can try adding this in your build and gradle.
kotlinOptions {
jvmTarget = "1.8"
}

Related

ssl certificate issue for jgit in javafx app image versus javafx app runtime

I have developed a simple JavaFX app using jgit, that is allowing users to play with git.
When the app was started from the IntelliJ idea, I was able to clone the GitHub repo using my jgit implementation of the "git clone" command without any issues. But as soon as I created an image from my app and started the app from the image, I am getting an SSL certificate issue:
Exception:org.eclipse.jgit.api.errors.TransportException:
Secure connection to https://my-github-repo.git could not be established because of SSL problems.
I am trying to understand why I am getting the SSL certificate issue only when I am running the app from the image. Can somebody explain that? I understand that I can disable SSL verification (there are some questions answered on that topic), but I want to know why it is working from IDE and not from the created image...
here is my simplified git clone implementation for http:
try {
CloneCommand command = Git.cloneRepository();
command.setCredentialsProvider(new UsernamePasswordCredentialsProvider(httpUsername, httpPassword));
// run the clone command
command.setURI(repositoryUrl);
command.setDirectory(dirFramework);
git = command.call();
} catch (Exception e) {
LOG.error("Error occurred during task: Git clone: " + e);
}
For creating the image I am using the "org.beryx.runtime" plugin with the Gradle task "runtime".
Here is the build.gradle content:
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.8'
id 'org.beryx.runtime' version '1.11.4'
}
group 'org.sovap'
version '1.0-SNAPSHOT'
sourceCompatibility = 11
targetCompatibility = 11
repositories {
mavenCentral()
}
dependencies {
// xml stuff
compile 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.3'
compile 'org.glassfish.jaxb:jaxb-runtime:2.3.2'
compile 'jakarta.activation:jakarta.activation-api:1.2.2'
// logger
compile 'org.apache.logging.log4j:log4j-core:2.13.3'
compile 'org.slf4j:slf4j-api:1.7.30'
compile 'org.slf4j:slf4j-simple:1.7.30'
// cucumber
compile 'io.cucumber:gherkin:15.0.2'
// jgit
compile 'org.eclipse.jgit:org.eclipse.jgit:5.9.0.202009080501-r'
compile 'org.eclipse.jgit:org.eclipse.jgit.archive:5.9.0.202009080501-r'
compile 'org.eclipse.jgit:org.eclipse.jgit.ssh.jsch:5.9.0.202009080501-r'
// file utils
compile 'commons-io:commons-io:2.7'
//controlsfx
compile 'org.controlsfx:controlsfx:11.0.2'
}
javafx {
version = "15"
modules = ['javafx.controls', 'javafx.fxml', 'javafx.web', "javafx.graphics"]
}
application {
mainClassName = 'org.sovap.taman.Launcher'
applicationName = 'taman'
}
runtime {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
imageDir = file("$buildDir/taman")
}
Edit 1:
How the image is created? - image is created with the plugin 'org.beryx.runtime' version '1.11.4', with Gradle task called 'runtime'. At the end of the build.gradle content you can see some specific configuration for runtime task.
Also, it is possible to include modules there as described here: https://badass-runtime-plugin.beryx.org/releases/latest/
I have tested the config with modules you are mentioning for runtime task in build.gradle (also one by one):
runtime {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
imageDir = file("$buildDir/taman")
modules = ['jdk.crypto.cryptoki', 'jdk.crypto.ec', 'jdk.crypto.mscapi']
}
But with that I am getting following exception when starting the app from image:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/stream/XMLStreamException
at org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory.newConfigurationBuilder(ConfigurationBuilderFactory.java:38)
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationBuilder.<init>(PropertiesConfigurationBuilder.java:72)
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory.getConfiguration(PropertiesConfigurationFactory.java:52)
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory.getConfiguration(PropertiesConfigurationFactory.java:35)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:551)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:475)
at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:323)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:687)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:708)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:602)
at org.sovap.taman.App.<clinit>(App.java:15)
at org.sovap.taman.Launcher.main(Launcher.java:6)
Caused by: java.lang.ClassNotFoundException: javax.xml.stream.XMLStreamException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
What version of Java 11 are you using? - java version "11.0.8" 2020-07-14 LTS
Regarding the different versions of JDK for image and for IntelliJ IDEA environment - it should be using the same installation on my machine
I guess I need to add modules to the runtime task, but I do not know which ones and how to identify them... Any direction you can point me to?
Edit 2:
According to the accepted answer, I was missing modules in my runtime task configuration. Here is how I have figured which ones to add:
The plugin 'org.beryx.runtime' contains a task I used for suggesting modules for the runtime task (task: suggestModules)
After running it I have created a list of modules with the following runtime config (included the ones from accepted answer):
runtime {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
imageDir = file("$buildDir/taman")
modules = [
'java.desktop',
'java.logging',
'java.xml',
'java.compiler',
'java.datatransfer',
'java.rmi',
'java.sql',
'java.naming',
'java.scripting',
'java.management',
'java.security.jgss',
'jdk.jfr',
'java.net.http',
'jdk.jsobject',
'jdk.xml.dom',
'jdk.unsupported',
'jdk.crypto.cryptoki',
'jdk.crypto.ec',
'jdk.crypto.mscapi']
}
Now everything works as expected.
The most likely situation is that you are missing a module in the JRE image related to crypto that is required to authenticate the SSL connection.
What jdk.crypto.* modules are in the final image?
Perhaps if one of these is missing it will affect the ability to handle the SSL certificates?
jdk.crypto.cryptoki
jdk.crypto.ec
jdk.crypto.mscapi
Since some aspects of the security/crypto code are done via service providers, perhaps when you generate the JRE image you should pass the
"--bind-services" option to "Link in service provider modules and their dependences"
You will need to share more details about how the image is created and what specific errors are reported. Try to include the full stack trace of any reported exceptions.
What version of Java 11 are you using?
Could you be running into this: JDK 11 SSL Error on valid certificate (working in previous versions)
(It is unlikely if you are running with the same JDK version in the IDE and the packaged image, but thought I would mention it just in case it gives you a hint.)

gradle nativeBinaries fails to satisfy dependencies

So, I wanted to generate native Kotlin binary for my app. I've came up with this build.gradle.kts:
plugins {
application
kotlin("multiplatform") version "1.3.70"
}
version = "1.0.2"
group = "org.gradle.sample"
repositories {
mavenCentral()
}
kotlin {
linuxX64("native") {
binaries {
executable()
}
}
}
dependencies {
implementation(kotlin("stdlib"))
implementation("io.javalin:javalin:3.8.0")
}
The code itself is simple:
package org.gradle.sample
import io.javalin.Javalin
fun main() {
val app = Javalin.create().start(7000)
app.get("/") { ctx -> ctx.result("Hello World") }
}
Problem here is that it fails when compiling, like if the dependencies were not satisfied:
> Task :compileKotlinNative FAILED
Caching disabled for task ':compileKotlinNative' because:
Build cache is disabled
Task ':compileKotlinNative' is not up-to-date because:
Task has failed previously.
file or directory '/home/keddad/Documents/samplekotlinapi/src/commonMain/kotlin', not found
file or directory '/home/keddad/Documents/samplekotlinapi/src/commonMain/kotlin', not found
Run tool: konanc with args: -g -ea -target linux_x64 -p library -o /home/keddad/Documents/samplekotlinapi/build/classes/kotlin/native/main/basic-api.klib -Xmulti-platform -no-endorsed-libs /home/keddad/Documents/samplekotlinapi/src/nativeMain/kotlin/org/gradle/sample/Main.kt
e: /home/keddad/Documents/samplekotlinapi/src/nativeMain/kotlin/org/gradle/sample/Main.kt: (3, 8): Unresolved reference: io
e: /home/keddad/Documents/samplekotlinapi/src/nativeMain/kotlin/org/gradle/sample/Main.kt: (6, 15): Unresolved reference: Javalin
e: /home/keddad/Documents/samplekotlinapi/src/nativeMain/kotlin/org/gradle/sample/Main.kt: (7, 20): Cannot infer a type for this parameter. Please specify it explicitly.
:compileKotlinNative (Thread[Execution worker for ':',5,main]) completed. Took 0.201 secs.
FAILURE: Build failed with an exception.
Same thing worked when compiling for JVM, but for Native it breaks. What am I doing wrong?
Unfortunately, you will not be able to compile this code at the moment. It seems like the Javalin framework is not targeting Kotlin/Native, it publishes only for Kotlin/JVM. The only libraries published with K/N in mind will be available to use.
In fact, the problem is that Kotlin flavors are not equivalent internally. They can share pure Kotlin code via common... source sets, but one cannot take a Kotlin/JVM project and just change the target. Kotlin/Native differs from the Kotlin/JVM, both of them are not the same as the Kotlin/JS. To make them work together, an approach named Kotlin/Multiplatform is recommended, see this article.
If you are interested in adapting this code to become multiplatform, consider looking at the Ktor. It provides support of the Kotlin/Native, and you'll be able to partially share code between platforms.

Gradle Kotlin Dsl Build for a Kotlin Gradle Plugin, which depends on a Groovy Class in the same Project

I have a Gradle plugin implemented with Kotlin, which is built with a gradle kotlin DSL build script. This works fine. The build script is as follows and is located in the buildSrc directory of project:
plugins {
groovy
`kotlin-dsl`
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
testImplementation(gradleTestKit())
implementation(kotlin("gradle-plugin"))
implementation ("com.bmuschko:gradle-docker-plugin:6.1.3")
}
Now i want to call a existing Groovy Class in the same buildSrc Source Tree from the Kotlin Plugin code. This works fine in Intellij.
But when building with gradle i get a : unresolved reference Class for the Groovy Class.
Looking at the build, i see that the compileKotlin task is executed first. When i uncomment the failing reference, i see that the groovyCompile produces the correct binaries.
So i tried this:
tasks.compileKotlin {
dependsOn(tasks.compileGroovy)
}
Naturally that is not good enough, but i tried to get the build to compile the Groovy code first.
I got the following error:
Circular dependency between the following tasks:
:buildSrc:compileGroovy
\--- :buildSrc:compileJava
\--- :buildSrc:compileKotlin
\--- :buildSrc:compileGroovy (*)
So i tried without succeeding , to remove the compileJava task dependency from compileGroovy:
tasks.compileGroovy {
dependsOn.remove(tasks.compileJava)
}
Some problem as above. Basically it is unclear to me how to remove precondigured taskdependencies in gradle
What i really need is something equivalent to gradle groovy build as :
compileGroovy.dependsOn = compileGroovy.taskDependencies.values - 'compileJava'
compileKotlin.dependsOn compileGroovy
compileKotlin.classpath += files(compileGroovy.destinationDir)
classes.dependsOn compileKotlin
How would look that like the Gradle Kotlin Dsl?
Or are there better ways to solve this Groovy / Kotlin Code Dependency problem?
Version Info:
------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------
Build time: 2019-02-08 19:00:10 UTC
Revision: f02764e074c32ee8851a4e1877dd1fea8ffb7183
Kotlin DSL: 1.1.3
Kotlin: 1.3.20
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 1.8.0_232 (AdoptOpenJDK 25.232-b09)
OS: Mac OS X 10.15.3 x86_64
I think this is equivalent, though I think it just knocks Java out of the picture, so Groovy/Kotlin/Java buildSrc code won't work...:
tasks {
val compileJava = named("compileJava", JavaCompile::class).get()
val compileKotlin = named("compileKotlin", KotlinCompile::class).get()
val compileGroovy = named("compileGroovy", GroovyCompile::class).get()
val classes by getting
compileGroovy.dependsOn.remove("compileJava")
compileKotlin.setDependsOn(mutableListOf(compileGroovy))
compileKotlin.classpath += files(compileGroovy.destinationDir)
classes.setDependsOn(mutableListOf(compileKotlin))
}
This has been vastly improved in Gradle 6.1
https://docs.gradle.org/6.1/release-notes.html#defining-compilation-order-between-groovy,-scala-and-java
And I'm not sure the above works for test ordering if they have unexpected language dependency ordering

Quarkus gradle test fails

I am trying to run the simple 'getting-started'-type gradle project with quarkus and my unit test fails everytime with this error
Caused by: io.quarkus.bootstrap.BootstrapException: Failed to locate project pom.xml for C:\Users\myuser\IdeaProjects\myproj\build\classes\java\main
Followed instructions here https://quarkus.io/guides/gradle-tooling
Any suggestions or thoughts on what is going on?
Gradle version details
Gradle 5.4
Build time: 2019-04-16 02:44:16 UTC
Revision: a4f3f91a30d4e36d82cc7592c4a0726df52aba0d
Kotlin: 1.3.21
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.2 (Oracle Corporation 11.0.2+9)
OS: Windows 10 10.0 amd64
btw. the problem is still open (current version 0.19.1) and issue (2307) is still unresolved.
The reason is that #QuarkusTest points to the QuarkusTestExtension, which in BootstrapClassLoaderFactory.newDeploymentClassLoader attempts to resolve local project with Maven.
We have options:
wait for official solution (see issue)
write own extension overriding BootstrapClassLoaderFactory to "understand" gradle project structure
apply a workaround (for time being), i.e. generate pom.xml from gradle build
Workaround
in build.grade:
plugins {
id 'java'
id 'io.quarkus' version '0.19.1'
// ...
id 'maven-publish'
}
// ...
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
// augment your pom here if necessary
}
}
}
// ...
task createPom(type: Copy) {
description 'This is workaround to generate pom.xml, needed for #QuarkusTest tests.'
dependsOn('generatePomFileForMavenJavaPublication')
from "$buildDir/publications/mavenJava/pom-default.xml"
into '.'
rename('pom-default.xml', 'pom.xml')
}
Note:
use 'maven-publish', not obsolete 'maven' plugin.
do not forget to apply ./gradlew createPom on dependencies changes

Switch to Kotlin 1.3.30 breaks hashCode only on Android API 21

I switched over my Android project from 1.3.20 to 1.3.30 and I am suddenly getting following exceptions from some of the classes when they call hashCode() method. Note, I am getting this exception only on Android platform API 21 & 22, beyond Android API 24, everything works fine.
Caused by: java.lang.NoSuchMethodError: No static method hashCode(J)I
in class Ljava/lang/Long; or its super classes (declaration of
'java.lang.Long' appears in /system/framework/core-libart.jar)
There is this thread that mentions similar symptoms but that was for Kotlin 1.2, I am wondering if anybody is encountering similar situation and if there is a workaround for this?
As an alternative, you may set a JVM target for Kotlin compilation to "1.6", as Kotlin 1.3.30 has started to infer the JVM target from the Java version in android.compileOptions and chooses "1.8" if both sourceCompatibility and targetCompatibility are set to that or higher.
In the module's build.gradle, add:
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = '1.6'
}
}
There will be no need to do this once the issue in D8 desugaring is fixed.
This issue is tracked in the Kotlin issue tracker as KT-31027.
This is related to this issue - https://issuetracker.google.com/issues/129730297 so solution seems to be to upgrade to latest AGP!