Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin 2.0 support #1614

Closed
rorbech opened this issue Dec 21, 2023 · 24 comments · Fixed by #1764
Closed

Kotlin 2.0 support #1614

rorbech opened this issue Dec 21, 2023 · 24 comments · Fixed by #1764
Assignees

Comments

@rorbech
Copy link
Contributor

rorbech commented Dec 21, 2023

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
Copy link
Contributor Author

rorbech commented Apr 15, 2024

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

@dhng22
Copy link

dhng22 commented Apr 16, 2024

Any plan for a version that supports Kotlin 2.0?

@rorbech
Copy link
Contributor Author

rorbech commented Apr 16, 2024

@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.

@dhng22
Copy link

dhng22 commented Apr 23, 2024

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

@toaster217
Copy link

Is there any progress?

@pkumar8888
Copy link

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.

This was referenced May 7, 2024
@dhng22
Copy link

dhng22 commented May 18, 2024

Any updates after 1 month?

@lehieu2602
Copy link

Any update? K2 has just released

@matsudamper
Copy link

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

@toaster217
Copy link

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

@yannickpulver
Copy link

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

@bidadh
Copy link

bidadh commented May 24, 2024

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

@Ash-333
Copy link

Ash-333 commented May 25, 2024

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

@rorbech
Copy link
Contributor Author

rorbech commented May 25, 2024

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

@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
Copy link
Contributor Author

rorbech commented May 25, 2024

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.

@Ash-333
Copy link

Ash-333 commented May 26, 2024

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')

@bidadh
Copy link

bidadh commented May 26, 2024

@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?

@maicol07
Copy link

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")

@bidadh
Copy link

bidadh commented May 27, 2024

@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")
  }
}

@maicol07
Copy link

@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

@eduardbosch
Copy link

@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

@bamsbamx
Copy link

bamsbamx commented Jul 3, 2024

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

@rorbech
Copy link
Contributor Author

rorbech commented Jul 3, 2024

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

@bamsbamx
Copy link

bamsbamx commented Jul 3, 2024

@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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.