在Module的build.gradle文件中添加以下代码示例:
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
// 添加以下代码
defaultConfig {
// ...
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// 下面两行代码是为了解决Logcat不显示日志级别的问题
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
// ...
}
然后重启Android Studio即可。