Created by Paris Tsiogas, Head of Mobile Development @ Desquared August 26, 2025
This guide walks you through implementing an encrypted Room database in a Kotlin Multiplatform (KMP) project, supporting both Android and iOS using SQLCipher. It covers Gradle, dependencies, code structure, and platform-specific setup.
In your libs.versions.toml
:
[versions]
sqlcipher = "4.9.0"
room = "2.7.0"
ksp = "2.1.21-2.0.2"
androidx-sqlite = "2.5.2"
[libraries]
room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
room-common = { module = "androidx.room:room-common", version.ref = "room" }
room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
androidx-sqlite = { module = "androidx.sqlite:sqlite", version.ref = "androidx-sqlite" }
androidx-sqlite-framework = { module = "androidx.sqlite:sqlite-framework", version.ref = "androidx-sqlite" }
android-sqlcipher = { module = "net.zetetic:sqlcipher-android", version.ref = "sqlcipher" }
In your plugins section:
[plugins]
kotlinCocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
androidx-room = { id = "androidx.room", version.ref = "room" }
Add to your Android module's build.gradle.kts
:
dependencies {
// ...other dependencies
implementation(libs.room.runtime)
}
Add to your iOS project:
pod 'SQLCipher', '~> 4.8.0'
In your root build.gradle.kts
add:
plugins {
...
alias(libs.plugins.kotlinCocoapods) apply false
}
In your shared module's build.gradle.kts
: