Version 2.7.0-alpha01
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.