Closed erksch closed 11 months ago
Hi! On the surface, this looks like https://youtrack.jetbrains.com/issue/KT-45044, but then it's unclear why the datetime library specifically could cause this.
When I remove kotlinx-datetime from my project it builds successfully.
Do you mean that just adding the dependency causes the problem? Or do you have to actually add code for the problem to occur?
Maybe it's something like that issue, but it is a different stacktrace. And in their case, it was related to Serialization, I think. Yes, it fails even with no code used from the library, only adding the dependency.
Yes, that issue is related to serialization.
The datetime library could cause serialization-related problems, since on Native it introduces a transitive dependency on the serialization library, version 1.2.1. Does adding a dependency on serialization 1.2.1 without adding a dependency on the datetime library work fine? Or do you maybe already depend on serialization? If so, on which version?
I had the same issue. I had datetime:0.1.1 and serialisation:1.1.0 before and it was working. Updating datetime to 0.2.1 caused the problem, while just updating serialisation did not. Updating both fixed the issue.
@Jahor Updating both to which versions?
With datetime @ 0.2.1 and serialisation @ 1.2.1 it works fine.
Sure, thanks, it also works for me.
So, I seem to be having a similar problem now since I have a Macbook M1. I needed to upgrade all libraries to the latest version to be able to run on an Arm Simulator. But now I cannot build the Release configuration because of this error. So I'm maintaining a build.gradle.kts file where I have older versions for these libraries for target iosArm64. Would be great if this could be fixed soon ...
Hi @neeohw, it seems that everyone else fixed this problem by updating their kotlinx.serialization
dependency as well, see above. Which versions do you depend on?
EDIT: also, which version of the Kotlin compiler are you using?
Hi @dkhalanskyjb, thanks for your response. So I am using the Kotlin 1.6.10 compiler.
I've upgraded the dependencies of kotlinx-datetime
to 0.3.2 and kotlinx-serialization-core
to 1.3.2.
What happens is that I have this NullPointerException when building for iosArm64Release. When I downgrade the packages to 0.2.1 and 1.2.2 and use Kotlin 1.5.31 I don't have a problem.
This is what my build.gradle.kts file looks like now:
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
kotlin("native.cocoapods")
id("com.android.library")
}
version = "1.0"
kotlin {
android()
iosX64()
iosArm64()
iosSimulatorArm64()
cocoapods {
summary = "Givt Code Share"
homepage = "https://github.com/givtnl/givt.apps.shared"
ios.deploymentTarget = "11.0"
framework {
baseName = "GivtCodeShare"
}
}
val ktorVersion = "1.6.5"
sourceSets {
val commonMain by getting { }
val commonTest by getting {
dependencies {
implementation("de.jodamob.kotlin:kotlin-runner-junit4:0.3.1")
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidMain by getting {
dependsOn(commonMain)
val datetimeVersion = "0.3.2"
val kotlinSerializationVersion = "1.3.2"
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-datetime:$datetimeVersion")
// Ktor networking
implementation("io.ktor:ktor-client-core:$ktorVersion")
// Ktor serialization
implementation("io.ktor:ktor-client-serialization:$ktorVersion")
// Kotlin serialization
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlinSerializationVersion")
implementation("io.ktor:ktor-client-android:$ktorVersion")
}
}
val androidTest by getting {
dependsOn(commonTest)
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13.2")
}
}
val iosSimulatorArm64Main by getting
val iosSimulatorMain by creating {
dependsOn(commonMain)
iosSimulatorArm64Main.dependsOn(this)
val datetimeVersion = "0.3.2"
val kotlinSerializationVersion = "1.3.2"
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-datetime:$datetimeVersion")
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-serialization:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlinSerializationVersion")
implementation("io.ktor:ktor-client-ios:$ktorVersion")
}
}
val iosX64Main by getting
val iosArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
val datetimeVersion = "0.2.1"
val kotlinSerializationVersion = "1.2.2"
val kotlinVersion = "1.5.31"
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-datetime:$datetimeVersion")
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-serialization:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlinSerializationVersion")
implementation("io.ktor:ktor-client-ios:$ktorVersion")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
}
}
val iosSimulatorArm64Test by getting
val iosX64Test by getting
val iosArm64Test by getting
val iosTest by creating {
dependsOn(commonTest)
iosX64Test.dependsOn(this)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
}
}
}
android {
compileSdk = 31
defaultConfig {
minSdk = 21
targetSdk = 31
}
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
}
It looks like you're having some other problem from the one initially reported. I am wary about iosMain
has a different kotlinSerializationVersion
from the one for iosSimulatorMain
: not sure how the dependency graph for this would look like in the end, but possibly, the compiler plugin for serialization became confused. Maybe try upgrading the dependencies everywhere so that they match?
If that fails, recommend filing this, including a stack trace for the NPE, to https://kotl.in/issue, because I don't see how something that we as a library are doing could cause this.
I will, thanks
By the way, I would like to stress the fact that before I created this dependency graph change on iosMain, I had all libraries and compiler on the latest versions. That's when I had this NullPointerException. Just to clarify:
Kotlin compiler: 1.6.10
kotlin-serialization: 1.6.10
kotlin-gradle-plugin: 1.6.10
kotlinx-serialization-core: 1.3.2
kotlinx-datetime: 0.3.2
Crash when build linkPodReleaseFrameworkIosArm64
Kotlin compiler: 1.6.10
kotlin-serialization: 1.5.31
kotlin-gradle-plugin: 1.5.31
kotlinx-serialization-core: 1.2.2
kotlinx-datetime: 0.2.1
No crash when build linkPodReleaseFrameworkIosArm64
Does anyone still encounter this, or can we close the issue?
Having the same problem when using the follow dependencies:
const val kotlin = "1.6.10"
const val ktor = "1.6.7"
const val kotlinxCoroutines = "1.6.1-native-mt"
const val kotlinxDateTime = "0.3.2"
when const val kotlinxSerialization > "1.3.0"
Does the issue reproduce with Kotlin 1.7.0, datetime 0.4.0, and serialization 1.3.2?
In the current project (with Compose for Desktop) when I upgrade to Kotlin 1.7.0 I start to get:
Failed to apply plugin 'org.jetbrains.kotlin.multiplatform'.
errors.
Does the issue reproduce with Kotlin 1.7.0, datetime 0.4.0, and serialization 1.3.2?
const val kotlin = "1.7.10"
const val ktor = "1.6.7"
const val kotlinxSerialization = "1.3.3"
const val kotlinxCoroutines = "1.6.3-native-mt"
const val kotlinxDateTime = "0.4.0"
Made it work with this combination 😉
I guess we need a very comprehensive matrix to understand which version work with whichever other versions :-)
Here I am again, with the following bundle:
const val kotlin = "1.7.20"
const val ktor = "2.1.2"
const val kotlinxSerialization = "1.4.0"
const val kotlinxCoroutines = "1.6.4"
const val kotlinxDateTime = "0.4.0"
Had to downgrade kotlinxSerialization
to 1.3.3 for successful build on iOS
Looks like no one encountered this with the last release. Let's hope the problem is gone, even if as mysteriously as it appeared.
Hey there!
I am using this library in a Kotlin Multiplatform Mobile project. All was fine until I began adding Pod dependencies to my Kotlin code, this adds the
linkReleaseFrameworkIos
task to the build process, which fails due tokotlinx-datetime
.The error is the following:
Complete Stacktrace
``` e: java.lang.NullPointerException at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable.mapClassReferenceType(DataFlowIR.kt:509) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable.mapType(DataFlowIR.kt:543) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable.mapTypeToFunctionParameter(DataFlowIR.kt:549) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable.mapFunction(DataFlowIR.kt:622) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable.access$mapFunction(DataFlowIR.kt:430) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitFunction(DataFlowIR.kt:461) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitConstructor(IrElementVisitorVoid.kt:55) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitConstructor(DataFlowIR.kt:455) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitConstructor(IrElementVisitorVoid.kt:56) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitConstructor(DataFlowIR.kt:455) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitConstructor(DataFlowIR.kt:455) at org.jetbrains.kotlin.ir.declarations.IrConstructor.accept(IrConstructor.kt:32) at org.jetbrains.kotlin.ir.declarations.IrClass.acceptChildren(IrClass.kt:61) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoidKt.acceptChildrenVoid(IrElementVisitorVoid.kt:275) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitClass(DataFlowIR.kt:472) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitClass(IrElementVisitorVoid.kt:44) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitClass(DataFlowIR.kt:455) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitClass(DataFlowIR.kt:455) at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:56) at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.acceptChildren(IrFileImpl.kt:66) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoidKt.acceptChildrenVoid(IrElementVisitorVoid.kt:275) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitElement(DataFlowIR.kt:457) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitPackageFragment(IrElementVisitorVoid.kt:30) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitPackageFragment(DataFlowIR.kt:455) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitFile(IrElementVisitorVoid.kt:37) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitFile(DataFlowIR.kt:455) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitFile(IrElementVisitorVoid.kt:38) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitFile(DataFlowIR.kt:455) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitFile(DataFlowIR.kt:455) at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.accept(IrFileImpl.kt:63) at org.jetbrains.kotlin.backend.konan.serialization.KonanIrModuleFragmentImpl.acceptChildren(KonanIrlinker.kt:253) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoidKt.acceptChildrenVoid(IrElementVisitorVoid.kt:275) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitElement(DataFlowIR.kt:457) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitModuleFragment(IrElementVisitorVoid.kt:27) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitModuleFragment(DataFlowIR.kt:455) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitModuleFragment(IrElementVisitorVoid.kt:28) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitModuleFragment(DataFlowIR.kt:455) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable$1.visitModuleFragment(DataFlowIR.kt:455) at org.jetbrains.kotlin.backend.konan.serialization.KonanIrModuleFragmentImpl.accept(KonanIrlinker.kt:250) at org.jetbrains.kotlin.backend.konan.optimizations.DataFlowIR$SymbolTable.When I remove
kotlinx-datetime
from my project it builds successfully. I know this is not much information, but would be glad to get some info on that!Versions:
Device: Apple MacBook Pro M1