- Room has been refactored into a Kotlin Multiplatform library, with most functionality common-ized and supported on Android, iOS, JVM (Desktop), native Mac and native Linux
- An overload of Room.databaseBuilder() that takes a factory lambda using the generated instantiateImpl function to avoid reflection when instantiating the RoomDatabase implementation
- RoomDatabase.Builder.setQueryCoroutineContext API for configuring a Room database with a CoroutineContext
- RoomDatabase.Builder.setDriver() API for configuring Room with a SQLite Driver
- RoomDatabase.useReaderConnection and RoomDatabase.useWriterConnection APIs for accessing the underlying SQLiteConnection from driver APIs
- Overloaded Migration.migrate, AutoMigrationSpec.onPostMigrate, and RoomDatabase.Callback onCreate, onDestructiveMigration and onOpen callbacks that receive SQLiteConnection instead of SupportSQLiteDatabase
- Kotlin code generation on KSP is turned on by default when processing via KSP, while KAPT or Java-only projects still generate Java sources
- The androidx.room:room-ktx artifact has been merged into androidx.room:room-runtime and is now blank, so it should be removed from dependency lists
From Room
Kotlin Multiplatform (KMP) Support: In this release, Room has been refactored to become a Kotlin Multiplatform (KMP) library. Although there is still some work to be done, this release introduces a new version of Room where the majority of the functionality has been common-ized (made to be multiplatform). Current supported platforms are Android, iOS, JVM (Desktop), native Mac and native Linux. Any missing functionality in the newly supported platforms will be made feature-complete in upcoming Room releases. For more information on how to get started using Room KMP, please refer to the official Room KMP documentation. Kotlin Code Generation on KSP has been turned ON by default if processing is done via KSP. For KAPT or Java only projects, Room will still generate Java sources. An overload of Room.databaseBuilder() has been added that takes a lambda parameter that is meant to be used with a Room generated function to avoid using reflection when instantiating the generated RoomDatabase implementation. Example usage is: Room . databaseBuilder ( context = appContext , name = dbFilePath , factory = { MyDatabase :: class . instantiateImpl () } ). An API for configuring a Room with a CoroutineContext has been added to the builder: RoomDatabase.Builder.setQueryCoroutineContext. Note that a RoomDatabase can only be configured with either executors using setQueryExecutor or with a Coroutine context but not both. An API for configuring Room with a SQLite Driver has been added: RoomDatabase.Builder.setDriver(). For more information about the SQLite Driver API refer to the SQLite KMP documentation. APIs for accessing the underlying SQLiteConnection from driver APIs have been added: RoomDatabase.useReaderConnection and RoomDatabase.useWriterConnection. Varios Room related callbacks now have an overloaded version that receive SQLiteConnection instead of SupportSQLiteDatabase. These are intended to be overridden when migrating to a KMP project. For more information about migrating Room usages in an Android app to a common KMP module refer to the migration guide. The callbacks are: Migration.migrate(SQLiteConnection), AutoMigrationSpec.onPostMigrate(SQLiteConnection), RoomDatabase.Callback.onCreate(SQLiteConnection), RoomDatabase.Callback.onDestructiveMigration(SQLiteConnection), RoomDatabase.Callback.onOpen(SQLiteConnection). The KTX artifact androidx.room:room-ktx has been merged to androidx.room:room-runtime along with all its APIs, the artifact is now blank. Please remove it from your dependency list.