Search code examples
androidkotlingradlekotlin-multiplatformkotlin-multiplatform-mobile

Is it possible to import a normal Kotlin library into Kotlin Mutliplatform Mobile


Is there a way to import a normal Kotlin Library (with only data classes) into a multiplatform project. If yes please provide source :)

OR

Must I use the Kotlin Multiplatform Library Template to provide simple information.

I want to import it into all parts of KMM (Common, Android, ...). As I want to use the library in a Spring Boot (Kotlin) backend too, I thought using KMM Library would not work there.

Thankful for any help!


Solution

  • jar is JVM specific, so you could use it in your Kotlin/JVM part, not in common/shared code.

    For sharing DTOs you could look at this example: https://github.com/halcyonmobile/MultiplatformPlayground#module-hierarchy

    where commonModel shares keys and DTOs between a JVM backend and a KMM common code