Using Kotlin/JS and Kotlin/Native on Android
summary
Demonstrates compiling the same Kotlin implementation for JVM, JavaScript, and native and swapping implementations behind an interface so Android code can call a JS or native version without changing app logic. Uses Kotlin Multiplatform and Gradle to emit JVM/JS/native artifacts, a DuckTape engine to host JS on Android, manual JNI plumbing for native, and Kotlinx.serialization to pass complex objects. Builds a Cash-like second-line string renderer, runs it on all three backends successfully, but notes packaging, name-mangling and main-thread blocking issues. DuckTape engine JNI bridge Kotlinx.serialization
AI-written summary · about
chapters (15)
- 0:00Introduction
- 1:09JavaScript on Android
- 6:42Native code on Android
- 8:10Kotlin Multiplatform basics
- 9:12Abstractions and interfaces
- 10:36Combining the concepts
- 12:39Demo setup
- 15:49Java bytecode implementation
- 16:30JavaScript backend with DuckTape
- 21:03Switching to JavaScript
- 22:05Native backend challenges
- 25:13Roadblocks and solutions
- 28:04Serialization for complex objects
- 31:33When to use this approach
- 33:18Summary and conclusion
related talks
33mUsing Kotlin for JS Client and JVM Server
40mKMP with non-Kotlin languages
48mKotlin for Android, iOS & the mobile web
34mKotlin Multiplatform: code sharing without compromise
46mKotlin/Anywhere
39mAn Overview of Multiplatform Kotlin
48mKotlin/Anywhere
39mArchitecting a Kotlin JVM and JS Multiplatform Project
