is it possible to use 3rd party libraries which ar...
# multiplatform
m
is it possible to use 3rd party libraries which are say platform specific? For example, tensorflow lite which is used in android/iOS. Iam including tensorflow lite as a dependency in jvmMain but I am not able to import it in my samplejvm.kt inside commonJVM module.
g
yes it’s possible
what is commonJVM module? Module shared between Android and JVM apps?
m
Hi, thanks for the response. so when we create a project in intellij using kotlin multiplatform library, three folders are generated namely, commonMain, jsMain and jvmMain.(when I said commonJVM I was referring to jvmMain directory)
Basically, I would like to use tensorflow for writing a common module using kotlin multiplatform and would like to use this common module across multiple platforms. I am initially focusing on web and android.
could you explain, how it is possible?
g
Right, commonMain cannot depend on tesonsorflow directly, until there is special MPP version of it
so you should define common interface and implement it in platform specific code
Also see this tutrorial, it shows simple example of usage platform specific libraries
m
@Kris Wong I am facing issues with setting up the project regarding a c library in kotlin multiplatform, could you provide a project repo link so I can use a working template?
@Kris Wong Thanks for the blog, now I am able to build the project. I have one doubt though, I am trying to build a library which can be served across android, iOS using Kotlin multiplatform plugin. In the functionality that I am trying to provide, the functionality uses tensorflow-lite library. what is the best way to include this library in a kmp project according to you?
k
never used it
👍 1