# Isuru Rajapakse

Stories by Isuru Rajapakse on Medium

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Bring your KMP library to NuGet

DevFeed: [Bring your KMP library to NuGet](<https://devfeed.tech/articles/bring-your-kmp-library-to-nuget-25915.md>)

Original publisher: [Read original article](<https://proandroiddev.com/bring-your-kmp-library-to-nuget-02e1131a4707?source=rss-43bae76e8f81------2>)

Author: Isuru Rajapakse

Published: 2026-07-19T13:17:14Z

Content type: release

Language: en

Sources: [Isuru Rajapakse](<https://devfeed.tech/sources/stories-by-isuru-rajapakse-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [NuGet](<https://devfeed.tech/topics/nuget.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [Boilerplate](<https://devfeed.tech/topics/boilerplate.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>)

Tags: [abi](<https://devfeed.tech/tags/abi.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [coroutines-flow](<https://devfeed.tech/tags/coroutines-flow.md>), [dotnet](<https://devfeed.tech/tags/dotnet.md>), [ffi](<https://devfeed.tech/tags/ffi.md>), [flow](<https://devfeed.tech/tags/flow.md>), [generics](<https://devfeed.tech/tags/generics.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [gradle-plugin](<https://devfeed.tech/tags/gradle-plugin.md>), [kmp](<https://devfeed.tech/tags/kmp.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [kotlin-native](<https://devfeed.tech/tags/kotlin-native.md>), [library](<https://devfeed.tech/tags/library.md>), [net](<https://devfeed.tech/tags/net.md>), [nuget](<https://devfeed.tech/tags/nuget.md>), [nuget-package](<https://devfeed.tech/tags/nuget-package.md>)

### AI overview

kotlin-native-nuget is an experimental Gradle plugin for packaging Kotlin/Native libraries as NuGet packages with generated C# bindings, and for generating Kotlin bindings to selected C# NuGet APIs. For Kotlin-to-C#, it processes the public API at build time, generates an Interop.cs file, compiles target-specific shared libraries, and packages both for .NET; consumers need no extra tooling. The article shows mappings for classes, enums, data classes, collections, generics, nullable values, interfaces, suspend functions, Flow, and cancellation. Runtime calls cross the C ABI through P/Invoke. In the reverse direction, developers select C# namespaces and can use generated Kotlin-idiomatic bindings. The author cautions that the plugin is 0.x and experimental, reverse support is still developing, and some Kotlin constructs are unsupported.

### Source excerpt

with kotlin-native-nuget plugin, you can bring your Kotlin to C# idiomaticallyhttps://medium.com/media/0f185efc67390bbf440bfc33f5675f42/href A little while ago, I gave a talk where I tried to take a library written in Kotlin and hand it to a .NET developer as a NuGet package. By hand. It is 30 minutes of me walking into every brick wall you can imagine - the C ABI, marshalling strings, keeping objects alive across the boundary, making any of it look like C# a human would actually want to use. Introducing kotlin-native-nuget 🪟kotlin-native-nuget plugin auto-binds your kotlin api into C# I turned all of that into a plugin, so you don't have to hit a single one of those walls. You write Kotlin, and out the other side comes a NuGet package with a proper, idiomatic C# API: classes, enums, data classes, coroutines, Flow, generics, interfaces, the works. No FFI boilerplate, no hand-written [DllImport], no "here's a C header, good luck". Your friends over in .NET just `dotnet add package` it and use it like it was C# all along. It's called kotlin-native-nuget, and it's a Gradle plugin. Here's the pitch: GitHub - xxfast/kotlin-native-nuget: A plugin that packages a Kotlin/Native library as a NuGet package with generated C# bindings, and consumes C# NuGet packages from Kotlin The pitch 🛗plugins { kotlin("multiplatform") id("io.github.xxfast.kotlin.native.nuget") version "<version>" } kotlin { mingwX64 { binaries { sharedLib { baseName = "mycatlib" } } } macosArm64 { binaries { sharedLib { baseName = "mycatlib" } } } } nuget { publish { packageId = "MyCatLib" version = "1.0.0" authors = "yourname" description = "My Kotlin/Native library" rootPackage = "com.example.cats" } } That's it. Add the plugin, point it at your native targets, and run the publish task. Out pops a .nupkg. Why though? 🤔 It's a fair question. I got it a lot (even on that talk) Kotlin Multiplatform already reaches an absurd number of places: the JVM, Android, iOS, JS, Wasm, and native desktop. But there's th

## Do-It-Yourself Compose Multiplatform Navigation with Decompose

DevFeed: [Do-It-Yourself Compose Multiplatform Navigation with Decompose](<https://devfeed.tech/articles/do-it-yourself-compose-multiplatform-navigation-with-decompose-25916.md>)

Original publisher: [Read original article](<https://proandroiddev.com/diy-compose-multiplatform-navigation-with-decompose-94ac8126e6b5?source=rss-43bae76e8f81------2>)

Author: Isuru Rajapakse

Published: 2023-02-09T09:02:35Z

Content type: tutorial

Language: en

Sources: [Isuru Rajapakse](<https://devfeed.tech/sources/stories-by-isuru-rajapakse-on-medium.md>)

Topics: [compose-multiplatform](<https://devfeed.tech/topics/compose-multiplatform.md>), [multiplatform](<https://devfeed.tech/topics/multiplatform.md>), [Library](<https://devfeed.tech/topics/library.md>), [parcelable](<https://devfeed.tech/topics/parcelable.md>), [Process](<https://devfeed.tech/topics/process.md>)

Tags: [abstraction](<https://devfeed.tech/tags/abstraction.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [api](<https://devfeed.tech/tags/api.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [component](<https://devfeed.tech/tags/component.md>), [compose](<https://devfeed.tech/tags/compose.md>), [compose-multiplatform](<https://devfeed.tech/tags/compose-multiplatform.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [death](<https://devfeed.tech/tags/death.md>), [desktop](<https://devfeed.tech/tags/desktop.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [library](<https://devfeed.tech/tags/library.md>), [multiplatform](<https://devfeed.tech/tags/multiplatform.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [parcelable](<https://devfeed.tech/tags/parcelable.md>), [parcelize](<https://devfeed.tech/tags/parcelize.md>), [process](<https://devfeed.tech/tags/process.md>), [router](<https://devfeed.tech/tags/router.md>), [scope](<https://devfeed.tech/tags/scope.md>), [use-case](<https://devfeed.tech/tags/use-case.md>)

### AI overview

The article shows how to share Compose Multiplatform navigation between Android and Desktop using Decompose without adopting its full Component architecture. A `Router<C>` wraps Decompose's stack navigation and child stack; `RoutedContent` supplies each child's component context, and `rememberRouter` creates the stack. A `rememberViewModel` hook uses Essenty's `InstanceKeeper` to retain view models per screen and clear them when that screen leaves the stack. For process-death restoration, it pairs a `SavedStateHandle` with Essenty's `StateKeeper`; only Parcelable state can be retained this way. The approach lets the author keep a preferred architecture while using Decompose's navigation, lifecycle, and saved-state facilities. The excerpt says the implementation was also published as Decompose-Router and notes that other issues could still foil the approach.

### Source excerpt

How to survive configuration changes, survive process death and scope ViewModels without going all-in with Decompose 🫢 Decompose recently went 1.0.0 🙌. I think it's a good opportunity to share my specific use case with Decompose where I use it to share navigation logic between Android and Desktop, without going all in with Decompose's Component pattern. Here are some of the problems you would run into - in extracting the navigation to the shared code Abstraction of common navigation. Retaining and scoping your view models Restoring the view models state after the process death. Doesn't Decompose solve all these problems? Why not go all in? This was really just a preference. I wanted to do my own architecture for my app and an inheritance-based component approach wasn't my forte. Luckily Decompose allows you to use parts of it and couple your navigation with business logic (if you want to). Decompose provides you with extensive customisation options to tailor the library to your needs. That's what I ended up doing at the end An Update! 📰 I've decided to publish the implementations of this article as a library called Decompose-Router. This should save you some time if you want to implement this on your own app. If you don't care about the implementation details and just want to use the library, head over there. GitHub - xxfast/Decompose-Router: A Compose-multiplatform navigation library that leverage Decompose to create an API inspired by Conductor The Goal 🥅 This is what we will be working towards. @Parcelize sealed class Screen: Parcelable { object List : Screen() data class Details(val detail: String) : Screen() } @Composable fun ListDetailScreen() { val router: Router<Screen> = rememberRouter(listOf(List)) RoutedContent( router = router, animation = stackAnimation(slide()), ) { screen -> when (screen) { List -> ListScreen(onSelect { detail -> router.push(detail) } ) is Details -> DetailsScreen(screen.detail) } } } @Composable fun ListScreen(onSelect: (detail: Stri

## KStore

DevFeed: [KStore](<https://devfeed.tech/articles/kstore-25913.md>)

Original publisher: [Read original article](<https://medium.com/@xxfast/kstore-1be37dd7bc22?source=rss-43bae76e8f81------2>)

Author: Isuru Rajapakse

Published: 2022-10-02T16:01:17Z

Content type: article

Language: en

Sources: [Isuru Rajapakse](<https://devfeed.tech/sources/stories-by-isuru-rajapakse-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Tool](<https://devfeed.tech/topics/tool.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Software Testing](<https://devfeed.tech/topics/software-testing.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [CI/CD](<https://devfeed.tech/topics/cicd.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [delete](<https://devfeed.tech/tags/delete.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [documentation](<https://devfeed.tech/tags/documentation.md>), [flow](<https://devfeed.tech/tags/flow.md>), [github](<https://devfeed.tech/tags/github.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [integration](<https://devfeed.tech/tags/integration.md>), [interface](<https://devfeed.tech/tags/interface.md>), [jetbrains](<https://devfeed.tech/tags/jetbrains.md>), [json](<https://devfeed.tech/tags/json.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [kotlinx](<https://devfeed.tech/tags/kotlinx.md>), [library](<https://devfeed.tech/tags/library.md>), [multiplatform](<https://devfeed.tech/tags/multiplatform.md>), [mutex](<https://devfeed.tech/tags/mutex.md>), [release](<https://devfeed.tech/tags/release.md>), [repository](<https://devfeed.tech/tags/repository.md>)

### AI overview

KStore is a Kotlin Multiplatform library for saving and restoring objects on disk with kotlinx.coroutines, kotlinx.serialization and Okio. Its API creates a store for a file path and offers suspended get, set, delete and reset operations, plus a Flow of updates. The update operation applies a change under one mutex-lock transaction; the article contrasts this with calling get() and then set() separately. The author describes building and testing each platform through GitHub Actions, tracking unit-test coverage with Kotlinx Klover, and checking binary compatibility with JetBrains' validator. The library is described as available from Maven Central; the excerpt does not detail platform support beyond mentioning multiplatform builds.

### Source excerpt

A tiny Kotlin multiplatform library to save and restore objects to and from the disk So I put out a new library, my first Multiplatform library. KStore is a tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serializationand okio Why? A newer version of kotlinx.serialization was released and one thing caught my eye Integration with Okio's BufferedSource and BufferedSink Release 1.4.0-RC - Kotlin/kotlinx.serialization However, there was little to no documentation on how to use it. I scanned through the repository looking for tests but couldn't find any. I asked on slack Got nothing.. But I pulled it down and tried it out anyways. dependencies { implementation("org.jetbrains.kotlinx:kotlinx-serialization-json-okio:1.4.0") } Tried out the most obvious way and wrote up a test case Json.encodeToBufferedSink(value, FILE_SYSTEM.sink(path).buffer()) No luck. Asked around on slack once again Not a minute went by, and our lord and saviour himself descended from heaven to help me out After using use, it worked 🙌. His divinely presence inspired me to write out a bunch more test cases and put this out there in under ~48hrs GitHub - xxfast/KStore: A tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serialisation and okio API KStore is inspired by RxStore, and it provides a simple API. Most of these interface methods are suspended, and can only be invoked from a suspended context. SuspendedCreate a storeval store: KStore<Pet> = storeOf("path/to/file")Get valueval mylo: Pet? = store.get() Or observe for changes val pets: Flow<Pet?> = store.updatesSet valuestore.set(mylo)Update a valuestore.update { pet: Pet? -> pet?.copy(age = pet.age + 1) } Note: this maintains a single mutex lock transaction, unlike get() and a subsequent set() Delete/Reset valuestore.delete() You can also reset a value back to its default. store.reset()Sel

## Unconfined Enums Adapter for Moshi

DevFeed: [Unconfined Enums Adapter for Moshi](<https://devfeed.tech/articles/unconfined-enums-adapter-for-moshi-25914.md>)

Original publisher: [Read original article](<https://medium.com/@xxfast/unconfined-enums-adapter-for-moshi-5d84542c8bf0?source=rss-43bae76e8f81------2>)

Author: Isuru Rajapakse

Published: 2022-05-11T12:08:49Z

Content type: article

Language: en

Sources: [Isuru Rajapakse](<https://devfeed.tech/sources/stories-by-isuru-rajapakse-on-medium.md>)

Topics: [enum](<https://devfeed.tech/topics/enum.md>), [adapter pattern](<https://devfeed.tech/topics/adapter-pattern.md>), [interface](<https://devfeed.tech/topics/interface.md>)

Tags: [adapter](<https://devfeed.tech/tags/adapter.md>), [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [converter](<https://devfeed.tech/tags/converter.md>), [enum](<https://devfeed.tech/tags/enum.md>), [enums](<https://devfeed.tech/tags/enums.md>), [interface](<https://devfeed.tech/tags/interface.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [mapping](<https://devfeed.tech/tags/mapping.md>), [moshi](<https://devfeed.tech/tags/moshi.md>), [need](<https://devfeed.tech/tags/need.md>), [retrofit](<https://devfeed.tech/tags/retrofit.md>)

### AI overview

The excerpt proposes replacing a finite Kotlin enum with an interface and an Unknown data class that retains an unrecognized API value, so Moshi can preserve values such as "Bananas" instead of throwing a JsonDataException or mapping them all to a fixed fallback. This makes the original server value available to application code, but an unrecognized value no longer has the enum's localized string-resource mapping. The excerpt cuts off before showing the complete adapter implementation.

### Source excerpt

If you wonder what an Unconfined Enum is, wonder no more because it is a thing I just made up. Enums by definition are confined, or finite. Therefore "unconfined enum" is really an oxymoron. Nevertheless, say you have this Fruit enum and want to map each value to an Android string resource. Kotlin's enum properties make this convenient enum class Fruit(@StringRes val stringRes: Int) { Apple(R.string.fruit_apple), Oranges(R.string.fruit_orange) } When we want to consume this enum from a Restful API with a Moshi converter, Moshi automatically generates the enum adapter for you, but if you want to customise the behaviour for whatever reason, you can do object FruitsAdapter { @ToJson fun toJson(type: Fruit): String = type.name @FromJson fun fromJson(name: String): Fruit = Fruit.values().first { it.name == name } } Happy days. Everything is working as expected. When things go bananascom.squareup.moshi.JsonDataException: Expected one of [Apple, Oranges] but was Bananas at path $ Good APIs don't break contracts. Not all APIs are good APIs, so some can break contracts. What do we do now? push out an update with added enum value and its string resource? Perhaps we can make use of EnumJsonAdapter's .withUnknownFallBack() enum class Fruit(@StringRes val stringRes: Int) { Apple(R.string.fruit_apple), Oranges(R.string.fruit_orange), Unknown(R.string.fruit_unknown) } Moshi.Builder() .add(KotlinJsonAdapterFactory()) .add(Fruit::class.java, EnumJsonAdapter.create(Fruit::class.java) .withUnknownFallback(Fruit.Unknown)) .build() This certainly stops the app from crashing, but what if we actually want to show the "bananas" that the API sends? you know, as a fail safe so that users wouldn't end up seeing "unknowns". Let's open up the Enums Enums are by definition finite. Enums are final by design. Enums can't be subclassed but they still can inherit interfaces. We will exploit this to create our "unconfined" enum interface Fruit { val name: String data class Unknown(override val name:

## Going Fully Multiplatform #1: Migrating your Android Project to Kotlin Multiplatform

DevFeed: [Going Fully Multiplatform #1: Migrating your Android Project to Kotlin Multiplatform](<https://devfeed.tech/articles/going-fully-multiplatform-1-migrating-your-android-project-to-kotlin-multiplatform-25912.md>)

Original publisher: [Read original article](<https://medium.com/@xxfast/going-fully-multiplatform-1-migrating-your-android-project-to-kotlin-multiplatform-8fc38763307?source=rss-43bae76e8f81------2>)

Author: Isuru Rajapakse

Published: 2021-10-21T13:24:07Z

Content type: article

Language: en

Sources: [Isuru Rajapakse](<https://devfeed.tech/sources/stories-by-isuru-rajapakse-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Android](<https://devfeed.tech/topics/android.md>), [compose-multiplatform](<https://devfeed.tech/topics/compose-multiplatform.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [koin](<https://devfeed.tech/topics/koin.md>), [Ktor](<https://devfeed.tech/topics/ktor.md>), [sqldelight](<https://devfeed.tech/topics/sqldelight.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [caching](<https://devfeed.tech/tags/caching.md>), [compose](<https://devfeed.tech/tags/compose.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [declarative](<https://devfeed.tech/tags/declarative.md>), [declarative-ui](<https://devfeed.tech/tags/declarative-ui.md>), [dependency-injection](<https://devfeed.tech/tags/dependency-injection.md>), [imperative](<https://devfeed.tech/tags/imperative.md>), [ios](<https://devfeed.tech/tags/ios.md>), [jetbrains](<https://devfeed.tech/tags/jetbrains.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [jvm](<https://devfeed.tech/tags/jvm.md>), [koin](<https://devfeed.tech/tags/koin.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [ktor](<https://devfeed.tech/tags/ktor.md>), [moshi](<https://devfeed.tech/tags/moshi.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [project](<https://devfeed.tech/tags/project.md>)

### AI overview

The author describes migrating a long-running Android-only app, targeting Android, JVM, iOS, and web. The existing stack uses OkHttp and Retrofit for networking, Moshi for serialization, Okio for caching, Koin, RxJava, Conductor, and XML Android Views. The planned multiplatform stack replaces these with Ktor, Kotlin Serialization, SQLDelight, Coroutine Flows, Decompose, and declarative UI with Jetpack/JetBrains Compose; Koin remains. The excerpt presents this as a plan and says later articles will cover the steps and project modularization, so it does not establish implementation results.

### Source excerpt

Earlier this year I started a mission to start migrating one of our long-lasting Android-only apps to Kotlin Multiplatform to go beyond just Android. This is the story of how that went. Migration from Only-Android to Kotlin Multiplatform!The Android stack This is our current "stack" our android app was set up as follows Targeting Android SDK API 23 or above, we had a few libraries to help us out. The Android-only stack OkHttp for Networking Retrofit for.. also Networking Moshi for serialisation Okio for caching Koin for Dependency Injection/ Service Locator Plumbing with RxJava Navigation with Conductor Imperative UI with Android Views written in XML The Multiplatform stack To go beyond just Android, I had to make some hard decisions to step outside of the comfort zone that we've been so fond of To target Android, JVM, iOS and Web -- we will be making use of The Multiplatform stack Ktor for Networking Kotlin Serialisation for.. serialisation Caching with SQLDelight Koin for Dependency Injection (that one can stay) Plumbing with Coroutine Flows Navigation with Decompose Declarative UI powered with Jetpack/Jetbrains Compose That's the plan! In the next few articles, we'll take a look at each step in more detail. Before jumping on to that -- I want to take a close look at how we can fully modularise a Kotlin Multiplatform project with Going Fully Multiplatform #2 Modularising your Kotlin Multiplatform Project!