The answer to this question is not "Android unit tests cannot access Android stack modules such as the Room database because on your desktop they are all stubbed out."
I had a bunch of unit tests that tested static methods that happened to be inside a Dao class - call it FooDao
. They all passed for a year until today, when they stopped passing when the Android Studio editor calls them. They still pass when the command line tests call them, but the editor reports:
java.lang.NoClassDefFoundError: androidx/sqlite/db/SupportSQLiteQuery
This happens when the unit test gets to FooDao.innocentStaticMethod()
. Like I said, accessing the FooDao
class without invoking any of its real Room methods formerly worked in unit tests.
The long-term fix is to refactor my code so FooDao
only contains real Room calls. But why did Android Studio's test runner suddenly stop working? The version is Android Studio 4.2 RC 1, built on March 23, 2021. And targetSdkVersion 30
.