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

Malachi de Ælfweald

07/05/2019, 2:23 PM
I am trying to put together a poc using cinterop inside mpp to create an android aar. Using androidNativeArm64 as the target, I was able to get cinterop to generate the klib files and deploy them to mavenLocal. I haven’t had much luck getting them consumed though. None of the packages in the auto-generated code are found. I tried using the includeBuild and specifying the dependencies on both the pom and the klib. Is there a code snippet somewhere that shows how to properly consume the .klib dependencies inside and Android library project?
I think it is a similar question to https://kotlinlang.slack.com/archives/C3PQML5NU/p1562184815101300 except I am using cinterop
h

h0tk3y

07/05/2019, 2:49 PM
The klib artifacts can only be consumed by the Kotlin/Native compiler. For Android, I guess you need to build a static binary (https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#building-final-native-binaries), then use it as a prebuilt NDK binary: https://developer.android.com/ndk/guides/prebuilts, https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs To call it from Java or Kotlin in the Android runtime, you'll need the JNI bindings as well.
m

Malachi de Ælfweald

07/05/2019, 3:08 PM
Ah, I thought cinterop was generating those.
h

h0tk3y

07/05/2019, 3:10 PM
Nope, cinterop is for calling native functions in Kotlin/Native.
m

Malachi de Ælfweald

07/05/2019, 3:20 PM
I appreciate the time. I’ll take a look.