Skip to content

Kotlin: Installing

The com.kizunasync:kizunasync artifact carries the client, the query helpers, and the host scheduler, and wraps the Rust engine through the UniFFI-generated uniffi.kizunasync_ffi bindings. The app adds supabase-kt, Supabase's own Kotlin client, beside it.

Add the Maven dependencies#

In the module build.gradle.kts:

// app/build.gradle.kts
dependencies {
    implementation("com.kizunasync:kizunasync:0.2.6-alpha.3")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1")
    implementation(platform("io.github.jan-tennert.supabase:bom:3.8.0"))
    implementation("io.github.jan-tennert.supabase:auth-kt")
    implementation("io.github.jan-tennert.supabase:realtime-kt")
    implementation("io.ktor:ktor-client-okhttp:3.4.0")
}

The artifact is an Android AAR whose POM depends on com.kizunasync:kizunasync-engine at the same version. The engine AAR carries the native kizunasync_ffi library for three ABIs (arm64-v8a, armeabi-v7a, x86_64). Gradle resolves the engine AAR as a transitive dependency, so the app module declares no engine line and needs no Rust toolchain. The client requires minSdk 26 and JDK 17. Its methods are suspending functions, and the client keeps kotlinx-coroutines off the app's compile classpath. The app declares kotlinx-coroutines-android itself, because its own code launches those calls and the Swift and Kotlin guide's TodoSync.kt imports kotlinx.coroutines.sync.Mutex.

The other lines add the coroutine runtime and supabase-kt, which Supabase documents under Kotlin: Installing, and the HTTP engine it runs on:

DependencyWhy the app needs it
org.jetbrains.kotlinx:kotlinx-coroutines-androidThe coroutine runtime the app's own code needs to call the client's suspending methods and to use Mutex and launch.
io.github.jan-tennert.supabase:bomsupabase-kt's bill of materials. It sets one version for every supabase-kt module, so the auth-kt and realtime-kt lines name none.
io.github.jan-tennert.supabase:auth-ktThe Auth plugin Supabase.kt installs. The app signs in with it, and the scheduler's refreshSession reads the access token from its session.
io.github.jan-tennert.supabase:realtime-ktThe Realtime plugin the Realtime wake adapter subscribes through, installed in Supabase.kt beside Auth. An app without that doorbell leaves out both the line and the plugin.
io.ktor:ktor-client-okhttpThe HTTP engine supabase-kt runs on, one of the Ktor client engines. OkHttp also opens the WebSocket that Realtime needs.

Import the client#

// app/src/main/kotlin/com/example/todo/TodoSync.kt (excerpt)
import com.kizunasync.kizunasync.KizunaSyncClient

The module should now resolve the types this reference documents, starting with KizunaSyncClient, KizunaSyncClientConfig, KizunaSyncQuery, and KizunaSyncScheduler from com.kizunasync.kizunasync. The next step is Initializing, which opens the local database and points the client at the Supabase project.

Found a problem? Edit this page on GitHub