Hello everyone. I'm trying to add a native android library as a dependency to my KMM project, but th...
s
Hello everyone. I'm trying to add a native android library as a dependency to my KMM project, but there are some errors showing up with internal dependencies (such as room, okhttp and kotlin coroutines ) when I add the dependency in my project's shared build.gradle (under commonMain sourceSet dependencies). I wanted to know, is there a way to generate a shared library for a native android library to be able to be used by both android and ios in a KMM app?
j
You can't use a pure Android dependency in common Kotlin code. You can use it in the Android target's source set.
If there is an iOS equivalent for the library, you can add that to the iOS target and use expect/actual or an injected interface/implementation to implement a common API that uses the platform-specific libraries on each platform.
s
Hmm okay got it, thank you!
👍🏼 1