dambakk
12/11/2019, 12:35 PMid("kotlinx-serialization") version "1.3.61"
to the plugins block and implementation(serialization("-common"))
dependency to commonMain. Then I try to annotate a data class with @Serializable
and IDEA says it fine, but when running gradle build it says Cannot access 'Serializable': it is internal in '<http://kotlin.io|kotlin.io>'
. It seems similar to this issue: https://github.com/Kotlin/kotlinx.serialization/issues/395 but here the solution was to add the plugin to the plugin block - which I have already done. Any suggestion what might cause this?turansky
12/11/2019, 2:16 PMdambakk
12/11/2019, 2:47 PMimport org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
group = "com.huma"
version = "0.0.1"
plugins {
kotlin("multiplatform")
id("kotlinx-serialization")
}
repositories {
mavenCentral()
jcenter()
maven(url = "<https://kotlin.bintray.com/kotlinx>")
maven(url = "<https://repo1.maven.org/maven2>")
maven(url = "<https://dl.bintray.com/kotlin/kotlin-eap>")
}
kotlin {
jvm("android") {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
//select iOS target platform depending on the Xcode environment variables
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64
iOSTarget("ios") {
binaries {
framework {
baseName = "Common"
}
}
}
sourceSets {
val ktorVersion = "1.2.6"
val coroutinesVersion = "1.3.2-1.3.60"
val serializationVersion = "0.14.0"
fun kotlinx(module: String, version: String) =
"org.jetbrains.kotlinx:kotlinx-$module:$version"
fun coroutines(module: String = "") =
kotlinx("coroutines-core$module", coroutinesVersion)
fun serialization(module: String = "") =
kotlinx("serialization-runtime$module", serializationVersion)
fun ktorClient(module: String, version: String = ktorVersion) =
"io.ktor:ktor-client-$module:$version"
all {
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
}
val commonMain by getting {
dependencies {
implementation(kotlin("stdlib-common"))
implementation(coroutines("-common"))
implementation(serialization("-common"))
implementation(ktorClient("core"))
implementation(ktorClient("json"))
implementation(ktorClient("serialization"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidMain by getting {
dependencies {
implementation(kotlin("stdlib"))
implementation(coroutines())
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}
val iosMain by getting {
dependencies {
implementation(coroutines("-native"))
}
}
val iosTest by getting {
}
}
}
// Some gradle tasks here...
Any obvious mistakes here?turansky
12/11/2019, 3:05 PMserialization-runtime
in every target (like in my example)turansky
12/11/2019, 3:06 PMserialization
declared for common
. js
& jvm
. In your example - only for common
dambakk
12/11/2019, 3:15 PMdambakk
12/11/2019, 3:15 PMdambakk
12/11/2019, 3:18 PMUnresolved reference: serialization
on import. But I can still cmd+click the import and inspect the source… 🙄turansky
12/11/2019, 3:49 PMStill the same errorIn common tests?
dambakk
12/11/2019, 6:16 PMpackage main.models
import kotlinx.serialization.*
@Serializable
data class AuthProvider(
val name: String,
val authUrl: String
)
IDEA says it is fine, I can even cmd+click serialization and view the source, but gradle gives me this error: Unresolved reference: serialization
dambakk
12/11/2019, 6:17 PMturansky
12/12/2019, 11:41 AM2019.3
some timesturansky
12/12/2019, 11:42 AMcommonTest
?dambakk
12/12/2019, 12:21 PMturansky
12/13/2019, 12:55 PMcommonTest
- the main suspectturansky
12/13/2019, 12:55 PM