https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
m

Mananpoddarm

06/03/2020, 6:28 AM
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

gildor

06/03/2020, 6:30 AM
yes it’s possible
what is commonJVM module? Module shared between Android and JVM apps?
m

Mananpoddarm

06/03/2020, 6:37 AM
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

gildor

06/03/2020, 9:14 AM
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

Mananpoddarm

06/04/2020, 7:17 AM
@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

Kris Wong

06/04/2020, 1:01 PM
never used it
👍 1