SDK InternalsSupported Platforms
Android
How the Platrium SDK builds for Android, with UniFFI Kotlin bindings and a Gradle library module.
The Android target produces shared libraries for arm64-v8a (devices and Apple Silicon emulators) and x86_64 (Intel emulators), plus the UniFFI-generated Kotlin bindings, in one Gradle library module the app depends on.
./nx run sdk:build:androidThat target runs three steps in order:
cargo ndkbuildslibplatrium_sdk.sofor both ABIs intosdk/_ffi/android/src/main/jniLibs.- The UniFFI generator reads the
arm64library and writesplatrium_sdk.ktintosdk/_ffi/android/src/main/java(packageuniffi.platrium_sdk). - Gradle assembles the module in
sdk/_ffi/android.
The app includes this module as :platrium-sdk (project(":platrium-sdk").projectDir = file("../sdk/_ffi/android")). Rebuild the SDK whenever the Rust API changes: the Kotlin types change with it, so an API change breaks the app's build instead of failing at runtime.
Using it from Kotlin
- Async calls (
createDownloadSession,streamTo,auth().exchangeCode,auth().me) aresuspendfunctions. Cancelling the calling coroutine cancels the Rust future. - Errors arrive as
PlatriumExceptionwith the casesUnauthorized,BadRequest,ApiExceptionandInternalException. - Authenticated clients come from
PlatriumClient.withToken(baseUrl, token).PlatriumClient(baseUrl)has no token and is only for the unauthenticated code exchange. - File descriptors:
DownloadDestination(fd)andUploadSource(fileName, fd)take a raw descriptor. The SDK takes ownership and closes it, so passParcelFileDescriptor.detachFd(), never a descriptor you still use. - Progress comes from
files().onTransferEvent(listener). Each call starts another subscription on the process-wide transfer manager, so subscribe once per client. - Rust
u64arrives as KotlinULong.
For how the app uses these, see the Android client.