When an Android app moves from Room 2.x to Room 3.0, what changes in the Gradle setup and the database builder, and what does getSupportWrapper() bridge?
answer
- new Maven group, new package
- KSP is the only processor
- a driver replaces the open helper
- bundled versus device SQLite
- SupportSQLiteDatabase view for legacy code
basics
~20 sRoom 3.0 moves to androidx.room3 artifacts and imports, runs only as a KSP processor that generates Kotlin, and opens databases through a SQLiteDriver instead of SupportSQLite; getSupportWrapper() from room3-sqlite-wrapper gives legacy code a SupportSQLiteDatabase over Room's connections.
solid answer
~30 sThree things change. Coordinates and imports: `androidx.room:room-runtime` becomes `androidx.room3:room3-runtime`, `androidx.room.*` becomes `androidx.room3.*`, and the Gradle plugin becomes `androidx.room3`. Code generation: `room3-compiler` runs only through `ksp(...)` and emits only Kotlin, so `kapt` and `annotationProcessor` wiring goes (KSP still reads Java sources). The builder: Room 3.0 always runs on a `SQLiteDriver`; `setDriver(AndroidSQLiteDriver())` uses the device's SQLite, `setDriver(BundledSQLiteDriver())` ships SQLite compiled from source, and `setOpenHelperFactory`, `openHelper` and `setQueryExecutor` are gone. For code that still speaks `SupportSQLiteDatabase`, `androidx.room3:room3-sqlite-wrapper` adds `roomDatabase.getSupportWrapper()` in place of `openHelper.writableDatabase`; its calls block the calling thread and journal-mode changes throw, so it is a bridge, not a destination.
code
kotlin · 16 lines// Module that owns the Room database: build.gradle.kts (excerpt)
plugins {
alias(libs.plugins.ksp)
alias(libs.plugins.androidx.room3)
}
room3 {
schemaDirectory("$projectDir/schemas")
}
dependencies {
implementation(libs.androidx.room3.runtime)
ksp(libs.androidx.room3.compiler)
implementation(libs.androidx.sqlite.bundled)
implementation(libs.androidx.room3.sqlite.wrapper)
}go deeper
Recall that Room 3.0 uses androidx.room3 artifacts and imports, needs KSP, and opens its database through a SQLiteDriver set on the builder.
Explain the driver choice, what disappeared from the builder, and how getSupportWrapper() keeps SupportSQLite callers compiling during the move.
Plan around the wrapper's costs, blocking calls and journal-mode limits, isolate Room in its own module, and keep libraries on Room 2.x working beside it.
Weigh the bundled driver's consistency and features against app size, and decide how long the wrapper may stay before callers must move to driver APIs.
## Why Room 3.0 is a separate library Room 3.0 (stable 3.0.0 on 1 July 2026, now 3.0.3) is a **new major in a new package**. Room 2.x lives in `androidx.room`; Room 3.0 in `androidx.room3`, with its own Maven group. The split is deliberate: libraries that use Room 2.x internally, WorkManager among them, keep working while the app moves, because the two majors share no class names. The annotations an engineer writes every day (`@Entity`, `@Dao`, `@Query`, `@Database`) keep their names. What changes is the build, the database builder and every line that touched `SupportSQLite`. ## The build | | Room 2.8.5 | Room 3.0 | |---|---|---| | Runtime artifact | `androidx.room:room-runtime` | `androidx.room3:room3-runtime` | | Compiler | `room-compiler` through `kapt`, `annotationProcessor` or `ksp` | `room3-compiler` through `ksp` only | | Generated code | Kotlin on KSP (the default since 2.7.0), Java on KAPT and javac | Kotlin only | | Gradle plugin | `androidx.room` with a `room { }` block | `androidx.room3` with a `room3 { }` block | | Package | `androidx.room` | `androidx.room3` | - KSP also reads **Java** sources, so Java entities and DAOs still compile; what is gone is processing through KAPT or javac. - The release notes recommend concentrating Room in **its own Gradle module**, so applying KSP and the Kotlin plugin there does not disturb the rest of the build. - Renames ride along, such as `@TypeConverter` becoming `@ColumnTypeConverter` in 3.0.0-rc01; the lesson on type converters covers them. ## The builder: a driver instead of an open helper Room 2.x on Android opened its file through a `SupportSQLiteOpenHelper`, replaceable with `setOpenHelperFactory`. Room 3.0 removes every `SupportSQLite` type from its API and runs on the **`SQLiteDriver`** interfaces from `androidx.sqlite`: 1. **`AndroidSQLiteDriver`** (`androidx.sqlite:sqlite-framework`) uses the SQLite that ships with the device, so its version, and features such as the FTS versions available, vary with the Android release. 2. **`BundledSQLiteDriver`** (`androidx.sqlite:sqlite-bundled`) packages SQLite compiled from source: one current version on every device and every FTS version regardless of API level, at the cost of a native library in the app. The Android multiplatform guides recommend it. 3. On Android, Room 3.0's builder falls back to `AndroidSQLiteDriver` when `setDriver` is never called, while on JVM and native targets `build()` fails with a message asking for `setDriver()`. Calling `setDriver` explicitly states the choice either way. The builder also loses `setOpenHelperFactory`, `setQueryExecutor` and `setTransactionExecutor`; a coroutine context replaces the executors, which the lesson on Room's coroutine support covers along with the rule that DAO functions suspend. ## The bridge: room3-sqlite-wrapper Code that still expects a `SupportSQLiteDatabase` (a raw-SQL helper, an older library, `openHelper.writableDatabase.execSQL(...)` scattered through repositories) need not be rewritten on day one. The artifact `androidx.room3:room3-sqlite-wrapper` adds the extension **`RoomDatabase.getSupportWrapper()`**, which returns a `SupportSQLiteDatabase` backed by Room's own connections. Know its limits: - Each call **blocks the calling thread** while it borrows a Room connection inside `runBlocking`, so keep wrapper callers off the main thread. - Journal-mode calls such as `enableWriteAheadLogging()` throw `UnsupportedOperationException`; the journal mode belongs on Room's builder (`setJournalMode`). - It is a **migration aid**, not a destination. The same wrapper exists on Room 2.8 as `androidx.room:room-sqlite-wrapper` (since 2.8.0), so a team can move legacy callers onto it before changing majors, then retire it caller by caller. ## The switch, step by step 1. Replace the `androidx.room:*` coordinates with `androidx.room3:*`, and every `kapt`, `annotationProcessor` or `ksp` line for the old compiler with a single `ksp(...)` for `room3-compiler`. 2. Swap the Gradle plugin and its block: `androidx.room` with `room { }` becomes `androidx.room3` with `room3 { }`, pointing at the schema directory you already use. 3. Rewrite imports from `androidx.room` to `androidx.room3`, including the renamed annotations. 4. Choose a driver on the builder and remove `setOpenHelperFactory` and the executor calls. 5. Point every `openHelper.writableDatabase` caller at `getSupportWrapper()`, then plan their retirement. ## What else moves, and where it is covered - DAO functions must be `suspend` unless they return a reactive type such as `Flow`; see the lesson on Room's coroutine support. - Migrations and database callbacks receive a `SQLiteConnection` instead of a `SupportSQLiteDatabase`; see the lesson on migrations. - `InvalidationTracker` observers give way to `createFlow()`, and LiveData, Paging and RxJava returns need DAO return type converters; both belong to the coroutine lesson.
- On Android, how do you choose between AndroidSQLiteDriver and BundledSQLiteDriver for Room 3.0?`AndroidSQLiteDriver` is the low-friction choice: no extra native library, the device's own SQLite. Pick `BundledSQLiteDriver` when one SQLite version everywhere matters, for example FTS versions an older Android release lacks, or a data layer shared with other platforms. The price is app size and taking SQLite upgrades through the `androidx.sqlite` releases.
- Can Room 2.x and Room 3.0 both be in one APK?Yes. Room 3.0 uses a new package and Maven group precisely so that libraries built on Room 2.x, WorkManager among them, keep working while the app's own database moves to `androidx.room3`. Each database file should still be managed by exactly one of them; two Room runtimes opening the same file would each track invalidation and connections separately.
- Why does a call through Room 3.0's getSupportWrapper() block the calling thread?`SupportSQLiteDatabase` is a synchronous API, while Room 3.0 lends out its connections through suspend functions. The wrapper bridges the two by borrowing a connection inside `runBlocking`, so the caller waits. On the main thread that risks jank or an ANR, so move wrapper callers to a background dispatcher first and then off the wrapper.
getSupportWrapper() is a plug adapter after moving abroad: old appliances work in the new sockets on day one, but each one is a little clumsier, and you replace them over time rather than living on adapters.
- Room 3.0 still accepts kapt for projects that cannot adopt KSP.
- Room 3.0 is a version bump, so the imports stay androidx.room.
- getSupportWrapper() is the long-term way to run raw SQL in Room 3.0.
- BundledSQLiteDriver uses the SQLite that ships with the device.
- setOpenHelperFactory still plugs a custom SupportSQLiteOpenHelper into Room 3.0.
Assumes Room 3.0.3 (androidx.room3) against Room 2.8.5; setDriver exists since Room 2.7.0 and the SupportSQLite wrapper since 2.8.0.