Search code examples
kotlin-multiplatformkotlin-multiplatform-mobile

How to avoid "libraries attached to project that were compiled with kotlin/native compiler" error?


I am working on a Kotlin Multiplatform Mobile project. Tried adding in libraries for KMM, but I am getting

There are __ third-party libraries attached to the project that were compiled with an older Kotlin/Native compiler and can't be read in IDE.

The android project builds without problem so I was wondering if whether this error is only a warning and doesn't not affect the application at all?

Is there anyway to avoid this issue? How can I know if a library could be used for Kotlin Native?


Solution

  • Kotlin/Native doesn't guarantee binary compatability between versions - although as of 1.4 minor versions are experimentally binary backwards compatible. e.g. 1.4.10 should be compatible with 1.4.20 in the same project.

    The easiest way to avoid the error is to ensure you're using KMM libraries with the same kotlin version as the kotlin version your project uses. Same goes for the IDE plugin.

    Generally kotlin libraries by Jetbrains stay very up to date, as well as bigger libraries like SqlDelight. But smaller third party libraries can fall behind.

    This issue is being actively worked on.