realm-kotlin icon indicating copy to clipboard operation
realm-kotlin copied to clipboard

Kotlin 2.0 support

Open rorbech opened this issue 1 year ago • 8 comments

The Realm Kotlin plugin is not compatible with K2.

Trying to build https://github.com/realm/realm-kotlin-samples/tree/main/Intro with 2.0.0-Beta2 yields:

There are some plugins incompatible with language version 2.0:
  io.realm.kotlin.compiler.Registrar
Please use language version 1.9 or below

rorbech avatar Dec 21 '23 12:12 rorbech

Update SDK code base to support compilation with K2 in #1721

rorbech avatar Apr 15 '24 09:04 rorbech

Any plan for a version that supports Kotlin 2.0?

dhng22 avatar Apr 16 '24 11:04 dhng22

@dhng22 With #1721 the SDK will actually compile with K2, but due to binary compatibilities we will have to ship separate distributables for 1.9 and 2.0. The intention is to make a branch compiled with K2 with a version suffix until things settles or we find another path. Intention is that this will happen within a week or three.

rorbech avatar Apr 16 '24 11:04 rorbech

@rorbech If there's any progress or change, please let me know, I'd love to track it

dhng22 avatar Apr 23 '24 02:04 dhng22

Is there any progress?

toaster217 avatar May 03 '24 02:05 toaster217

Hi guys, we've been waiting for this one as well. Any updates? As of now v1.16 also does not offer support for K2.

pkumar8888 avatar May 06 '24 13:05 pkumar8888

Any updates after 1 month?

dhng22 avatar May 18 '24 19:05 dhng22

Any update? K2 has just released

lehieu2602 avatar May 21 '24 14:05 lehieu2602

When will 2.0.0 be released? https://search.maven.org/artifact/io.realm.kotlin/gradle-plugin

matsudamper avatar May 24 '24 02:05 matsudamper

Issue closed, ReadMe updated to Realm 2.0.0 but Realm 2.0 isn't actually rolled out yet

toaster217 avatar May 24 '24 09:05 toaster217

Latest 2.0.0-SNAPSHOT is compatible with Kotlin 2.0 if you don't want to wait for the stable release. In README.md is a guide how to switch to snapshots

yannickpulver avatar May 24 '24 09:05 yannickpulver

Plugin [id: 'io.realm.kotlin', version: '2.0.0-SNAPSHOT', apply: false] was not found in any of the following sources:

  • Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
  • Included Builds (No included builds contain this plugin)
  • Plugin Repositories (could not resolve plugin artifact 'io.realm.kotlin:io.realm.kotlin.gradle.plugin:2.0.0-SNAPSHOT') Searched in the following repositories: maven(https://maven.pkg.jetbrains.space/public/p/compose/dev) maven2(https://oss.sonatype.org/content/repositories/snapshots) Google Gradle Central Plugin Repository

bidadh avatar May 24 '24 22:05 bidadh

Is there any update?

There are some plugins incompatible with language version 2.0: io.realm.kotlin.compiler.Registrar Please use language version 1.9 or below

Ash-333 avatar May 25 '24 05:05 Ash-333

Plugin [id: 'io.realm.kotlin', version: '2.0.0-SNAPSHOT', apply: false] was not found in any of the following sources:

  • Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
  • Included Builds (No included builds contain this plugin)
  • Plugin Repositories (could not resolve plugin artifact 'io.realm.kotlin:io.realm.kotlin.gradle.plugin:2.0.0-SNAPSHOT') Searched in the following repositories: maven(https://maven.pkg.jetbrains.space/public/p/compose/dev) maven2(https://oss.sonatype.org/content/repositories/snapshots) Google Gradle Central Plugin Repository

@bidadh It seems like the providers for version catalogs doesn't resolve plugins from the classpath, so you have to apply the plugin with

id("io.realm.kotlin")

instead of by alias or similar constructs. There is a PR in our samples repository showing this.

rorbech avatar May 25 '24 08:05 rorbech

Is there any update?

@Ash-333 There is no fixed date for when the 2.0.0 release will go out, but until that you can use the 2.0.0-SNAPSHOT following the instructions in the README.

rorbech avatar May 25 '24 08:05 rorbech

Is there any update?

@Ash-333 There is no fixed date for when the 2.0.0 release will go out, but until that you can use the 2.0.0-SNAPSHOT following the instructions in the README.

I am trying to use realm for KMP project targeting Android, iOS & Desktop

Exception is: org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'io.realm.kotlin', version: '2.0.0-SNAPSHOT', apply: false] was not found in any of the following sources:

  • Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
  • Included Builds (No included builds contain this plugin)
  • Plugin Repositories (could not resolve plugin artifact 'io.realm.kotlin:io.realm.kotlin.gradle.plugin:2.0.0-SNAPSHOT')

Ash-333 avatar May 26 '24 05:05 Ash-333

@rorbech It didn't work either. I've tried many options already and have had no success so far. I've decided to wait until 2.0.0 is released unless there is a clear way. When should we expect 2.0.0?

bidadh avatar May 26 '24 12:05 bidadh

I've found a way to get it to work. It seems the gradle plugin doesn't follow the classic gradle plugin name convention and it can't be resolved (i.e. tries to download it from https://oss.sonatype.org/content/repositories/snapshots/io/realm/kotlin/io.realm.kotlin.gradle-plugin/2.0.0-SNAPSHOT/maven-metadata.xml which gives 404).

The objective is to let it download the plugin from https://oss.sonatype.org/content/repositories/snapshots/io/realm/kotlin/gradle-plugin/2.0.0-SNAPSHOT/maven-metadata.xml

Following the README I've found the working combination:

Project build.gradle.kts (root) Remove the plugin from the plugins block and add the following:

buildscript {
    dependencies {
        classpath("io.realm.kotlin:gradle-plugin:2.0.0-SNAPSHOT")
    }
}

Module build.gradle.kts Ad the following to the plugins block:

id("io.realm.kotlin")

maicol07 avatar May 27 '24 15:05 maicol07

@maicol07 you still need to add repositories to your module's build.gradle.kts

repositories {
  maven {
    url = uri("https://oss.sonatype.org/content/repositories/snapshots")
  }
}

bidadh avatar May 27 '24 21:05 bidadh

@maicol07 you still need to add repositories to your module's build.gradle.kts

repositories {
  maven {
    url = uri("https://oss.sonatype.org/content/repositories/snapshots")
  }
}

Yeah, I have implied it

maicol07 avatar May 27 '24 21:05 maicol07

@rorbech It didn't work either. I've tried many options already and have had no success so far. I've decided to wait until 2.0.0 is released unless there is a clear way. When should we expect 2.0.0?

I've just seen that 2.0.0 was released yesterday 🙂 https://github.com/realm/realm-kotlin/releases/tag/v2.0.0

eduardbosch avatar Jun 04 '24 12:06 eduardbosch

Just updated to K2 and Realm version 2.0.0. It fails to compile with the following stack trace:

Executing tasks: [:app:assembleDebug, :app:assembleDebugUnitTest, :app:assembleDebugAndroidTest] in project C:\Users\110142\AndroidStudioProjects*****

Task :app:preBuild UP-TO-DATE Task :app:preDebugBuild UP-TO-DATE Task :app:mergeDebugNativeDebugMetadata NO-SOURCE Task :app:checkKotlinGradlePluginConfigurationErrors SKIPPED Task :app:dataBindingMergeDependencyArtifactsDebug Task :app:generateDebugResValues Task :app:generateDebugResources Task :app:mergeDebugResources Task :app:packageDebugResources Task :app:parseDebugLocalResources Task :app:checkDebugAarMetadata Task :app:dataBindingGenBaseClassesDebug Task :app:mapDebugSourceSetPaths Task :app:createDebugCompatibleScreenManifests Task :app:extractDeepLinksDebug Task :app:processDebugMainManifest Task :app:processDebugManifest Task :app:javaPreCompileDebug Task :app:mergeDebugShaders Task :app:compileDebugShaders NO-SOURCE Task :app:generateDebugAssets UP-TO-DATE Task :app:mergeDebugAssets Task :app:compressDebugAssets Task :app:processDebugManifestForPackage Task :app:checkDebugDuplicateClasses Task :app:mergeDebugStartupProfile Task :app:mergeLibDexDebug Task :app:configureCMakeDebug[arm64-v8a] Task :app:buildCMakeDebug[arm64-v8a] Task :app:configureCMakeDebug[armeabi-v7a] Task :app:buildCMakeDebug[armeabi-v7a] Task :app:configureCMakeDebug[x86] Task :app:buildCMakeDebug[x86] Task :app:configureCMakeDebug[x86_64] Task :app:buildCMakeDebug[x86_64] Task :app:mergeDebugJniLibFolders Task :app:validateSigningDebug Task :app:writeDebugAppMetadata Task :app:writeDebugSigningConfigVersions Task :app:preDebugUnitTestBuild UP-TO-DATE Task :app:preDebugAndroidTestBuild SKIPPED Task :app:javaPreCompileDebugUnitTest Task :app:dataBindingMergeDependencyArtifactsDebugAndroidTest Task :app:generateDebugAndroidTestResValues Task :app:generateDebugAndroidTestResources Task :app:mergeDebugNativeLibs Task :app:desugarDebugFileDependencies Task :app:mergeDebugAndroidTestResources Task :app:processDebugResources Task :app:mergeExtDexDebug Task :app:dataBindingGenBaseClassesDebugAndroidTest Task :app:mapDebugAndroidTestSourceSetPaths Task :app:checkDebugAndroidTestAarMetadata Task :app:processDebugAndroidTestManifest Task :app:mergeDebugAndroidTestShaders Task :app:compileDebugAndroidTestShaders NO-SOURCE Task :app:generateDebugAndroidTestAssets UP-TO-DATE Task :app:stripDebugDebugSymbols Task :app:javaPreCompileDebugAndroidTest Task :app:mergeDebugAndroidTestAssets Task :app:compressDebugAndroidTestAssets Task :app:desugarDebugAndroidTestFileDependencies Task :app:mergeDebugAndroidTestJniLibFolders Task :app:mergeDebugAndroidTestNativeLibs NO-SOURCE Task :app:stripDebugAndroidTestDebugSymbols NO-SOURCE Task :app:validateSigningDebugAndroidTest Task :app:checkDebugAndroidTestDuplicateClasses Task :app:writeDebugAndroidTestSigningConfigVersions Task :app:processDebugAndroidTestResources Task :app:mergeLibDexDebugAndroidTest Task :app:mergeExtDexDebugAndroidTest

Task :app:compileDebugKotlin FAILED e: java.lang.NullPointerException at io.realm.kotlin.compiler.SyncLowering.(SyncLoweringExtension.kt:64) at io.realm.kotlin.compiler.SyncLoweringExtension.generate(SyncLoweringExtension.kt:57) at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.applyIrGenerationExtensions(convertToIr.kt:260) at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.convertToIrAndActualize(convertToIr.kt:139) at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.convertToIrAndActualize$default(convertToIr.kt:65) at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.convertToIrAndActualizeForJvm(jvmCompilerPipeline.kt:193) at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.convertAnalyzedFirToIr(jvmCompilerPipeline.kt:167) at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.compileModulesUsingFrontendIrAndLightTree(jvmCompilerPipeline.kt:138) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:155) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:50) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:104) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:48) at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101) at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:453) at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:62) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.doCompile(IncrementalCompilerRunner.kt:506) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:423) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileNonIncrementally(IncrementalCompilerRunner.kt:301) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:129) at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:676) at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:92) at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1661) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360) at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200) at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197) at java.base/java.security.AccessController.doPrivileged(AccessController.java:712) at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:840)

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileDebugKotlin'.

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction Internal compiler error. See log for more details

bamsbamx avatar Jul 03 '24 11:07 bamsbamx

@bamsbamx Which version did you migrate from? And did you also remember to update the version of the realm-depenedencies?

rorbech avatar Jul 03 '24 11:07 rorbech

@bamsbamx Which version did you migrate from? And did you also remember to update the version of the realm-depenedencies?

My bad, I updated from 1.8.0, but just forgot to also update the dependencies. After updating, everything went ok:

io.realm.kotlin:library-base io.realm.kotlin:library-sync

bamsbamx avatar Jul 03 '24 12:07 bamsbamx