Skip to content

Kotlin

Add the binding to your common source set from Maven Central:

build.gradle.kts
repositories {
mavenCentral()
}
kotlin {
sourceSets {
commonMain.dependencies {
implementation("org.maplibre.nativeffi:maplibre-native-ffi:0.202611.0")
}
}
}

Then add a runtime to each target, as the sections below show. A runtime holds the native library for one backend: maplibre-native-ffi-runtime-opengl, -metal, -vulkan, or -webgpu.

Android needs API level 24 or later. Add a runtime to androidMain:

build.gradle.kts
androidMain.dependencies {
implementation("org.maplibre.nativeffi:maplibre-native-ffi-runtime-vulkan:0.202611.0")
}

Call initAndroid(context) once before you create a runtime.

Add a runtime to the source set of each native target, such as Metal for Apple platforms and Vulkan for Linux:

build.gradle.kts
appleMain.dependencies {
implementation("org.maplibre.nativeffi:maplibre-native-ffi-runtime-metal:0.202611.0")
}
linuxMain.dependencies {
implementation("org.maplibre.nativeffi:maplibre-native-ffi-runtime-vulkan:0.202611.0")
}

The JVM needs JDK 25 or later. Its runtime holds the native library in a separate JAR for each platform. Add the JAR for each platform that your application runs on, by its classifier: natives-<os>-<arch>, such as natives-linux-x64 or natives-macos-arm64. Use linux-musl for musl, and windows-mingw for MinGW on Windows.

build.gradle.kts
jvmMain.dependencies {
runtimeOnly("org.maplibre.nativeffi:maplibre-native-ffi-runtime-vulkan-jvm:0.202611.0:natives-linux-x64")
}

The binding calls native code through Java’s foreign function API, so start the JVM with --enable-native-access=ALL-UNNAMED.

Add the OpenGL runtime to wasmJsMain to render with WebGL, or the WebGPU runtime to render with WebGPU. Before you use the binding, call loadWasmModule() and wait for it. The page must meet the web requirements.

Snapshots of main publish daily to the Maven snapshot repository, as version 0.1.0-SNAPSHOT:

build.gradle.kts
repositories {
maven("https://central.sonatype.com/repository/maven-snapshots/") {
content { includeGroup("org.maplibre.nativeffi") }
}
mavenCentral()
}

Then use 0.1.0-SNAPSHOT as the version of the binding and its runtimes.