问题
I am using a Room database inside my project and it works in production including the UI-Tests (with Espresso) until Android 8. On Android 9 currently my UI-Tests fail because the Database is not created. I get the following error message inside my logcat
android.database.sqlite.SQLiteException: no such table: table (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM table WHERE type = ?
This only happens on Android 9 devices. While debugging with Stetho i can't find the db file aswell. On devices pre Android 9 the file is visible in Stetho. Does anyone face the same problem? Currently we are using the pre AndroidX Libraries for Room:
implementation "android.arch.persistence.room:runtime:${androidArchVersion}"
kapt "android.arch.persistence.room:compiler:${androidArchVersion}"
Or is it necessary to use the AndroidX Libraries for Devices with Android 9?
Any help is appreciated!
回答1:
It turned out that a close() was missing for the database after the Migration. In the production App everything was fine but inside the Tests + on Emulator the described error came up. Maybe its helpful for someone else!
来源:https://stackoverflow.com/questions/54185402/room-not-creating-database-in-ui-tests