Version 2.7.0-alpha06
Change the instantiation setup for a RoomDatabase in a KMP project. Due to Kotlin 2.0 compilation model, the strategy of referencing a to-be-generated function, named instantiateImpl() is longer viable. Two new APIs, @ConstructedBy and RoomDatabaseConstructor are introduced that replace the instantiateImpl() strategy. The new strategy is as follow: Define an expect object that implements RoomDatabaseConstructor expect object MyDatabaseCtor : RoomDatabaseConstructor Link the object with the @Database declaration using @ConstructedBy @Database (...) @ConstructedBy (MyDatabaseCtor : : class) // NEW abstract class MyDatabase : RoomDatabase Create a new database instance but without passing a factory argument fun createNewDatabase(path: String) = Room.databaseBuilder(name = path) .setDriver(BundledSQLiteDriver()) .setQueryCoroutineContext(Dispatchers.IO) .build() Fixes b/316978491, b/338446862, and b/342905180