Search code examples
androidandroid-room

Android: Room stopped working after upgrading to version 2.4.3


Android: The Room database stopped working after upgrading to version 2.4.3. The application complains about the AppDatabase_Impl generated file.

AppDatabase_Impl.java:72: error: onCreate(SupportSQLiteDatabase) in <anonymous com.mobile_solutions.mycar.database.AppDatabase_Impl$1> cannot override onCreate(SupportSQLiteDatabase) in Delegate protected void onCreate(SupportSQLiteDatabase _db) { ^ attempting to assign weaker access privileges; was public

AppDatabase:

@Database(
    entities = [
        Service::class,
        Profile::class,
        WorkItem::class,
        Auto::class,
        Recommendation::class,
        TechVisit::class,
        NotificationSimple::class,
        Expense::class
               ], version = 85, exportSchema = false
)
abstract class AppDatabase : RoomDatabase() {
    abstract fun myCarDao(): MyCarDao?
}

I am getting such error:

AppDatabase_Impl.java:72: error: onCreate(Support SQLite Database) in <anonymous com.mobile_solutions.mycar.database.AppDatabase_Impl$1> cannot override onCreate(SupportSQLiteDatabase) in Delegate
      protected void onCreate(SupportSQLiteDatabase _db) {
                 ^

attempting to assign weaker access privileges; was public

What to do about it?


Solution

  • I see a very related question solved 7 months ago:

    To fix this error for Jetpack Compose and Paging 3 you only need to use only this libraries

    //ROOM
    implementation "androidx.room:room-runtime:2.4.2"
    kapt "androidx.room:room-compiler:2.4.2"
    implementation "androidx.room:room-ktx:2.4.2"
    implementation "androidx.room:room-paging:2.4.2"
    
    // Paging 3.0
    implementation 'androidx.paging:paging-compose:1.0.0-alpha15'
    

    Hope this helps or try following some of the other suggestions from the source! Note I see this answer is about 2.4.3 specifically so check out an answer from the related question that came in December 2022 for that specifically.