Compiler Error when working with Jetpack Compose for Web
See original GitHub issueDescribe the bug When working with Serialization within the new Compose for Web library, I get a Compiler Error on trying to define Serializable data classes to interact with the public Pokemon API
To Reproduce Attach a code snippet or test data if possible.
models.kt
@Serializable
data class PokemonAPIResponse<T>(
val count: Int,
val next: String?,
val previous: String?,
val results: T
)
@Serializable
data class Pokemon(
val id: Int,
val name: String
)
build.gradle.kts
plugins {
kotlin("plugin.serialization") version "1.4.32"
kotlin("multiplatform") version "1.4.32"
id("org.jetbrains.compose") version "0.0.0-web-dev-11"
}
group = "org.marks0mmers"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
kotlin {
js(IR) {
browser()
binaries.executable()
}
sourceSets {
val jsMain by getting {
dependencies {
implementation(compose.web.web)
implementation(compose.runtime)
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.0")
}
}
}
}
Expected behavior Program to compile and be able to properly serialize these two classes
Environment
- Kotlin version: [e.g. 1.3.30] 1.4.32
- Library version: [e.g. 0.11.0] 1.2.0
- Kotlin platforms: [e.g. JVM, JS, Native or their combinations] JS
- Gradle version: [e.g. 4.10] 6.8
- IDE version (if bug is related to the IDE) [e.g. IntellijIDEA 2019.1, Android Studio 3.4] IntelliJIDEA 2021.1.1
- Other relevant context [e.g. OS version, JRE version, … ] Windows 10, JRE 11
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:8
Top Results From Across the Web
How to fix jetpack compose compiler error? - Stack Overflow
Project does not build because of compose compiler error. Adding "androidx.compose.compiler:compiler" dependency does not fix error.
Read more >[Solved]-Error finding jetpack compose compiler Could not ...
Coding example for the question Error finding jetpack compose compiler Could not find androidx.compose:compose-compiler:1.0.0-alpha11-kotlin.
Read more >Quick start | Jetpack Compose - Android Developers
The Compose Kotlin compiler extension (androidx.compose.compiler) is not linked to the Compose library versions. Instead, it is linked to versions of the Kotlin ......
Read more >What's new in Jetpack Compose - Android Developers Blog
They also shared “We rewrote the button component in our app using Compose. Before it required 800 lines of code across three files...
Read more >Inside Jetpack Compose - Medium
Change the Composable function to be able to create a SlotTable with the Compose Kotlin Compiler Plugin. After app launch. 1. Call the ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A workaround for now is creating a module without Compose that has your serializable classes, and then the Compose module without the Kotlinx Serialization plugin can depend on that module.
I haven’t tested everything yet, but it works for simple serialization/deserialization.![7wB7mttZHk](https://user-images.githubusercontent.com/9496359/117586746-75355080-b0f0-11eb-80ef-a955963dee47.gif)
Looks like this is a longstanding issue, also filed over at the compose repo: https://github.com/JetBrains/compose-jb/issues/738