Room not creating database in UI-Tests

风格不统一 提交于 2020-01-16 01:08:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!