运行环境
- Android Studio 4.1.1
- compileSdkVersion 29
- buildToolsVersion "29.0.2"
点击绿色锤子「make project」出现以下错误
Default interface methods are only supported starting with Android N (--min-api 24):
Landroidx/room/migration/AutoMigrationCallback;onPostMigrate(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
解决办法:
在模块的gradle里的android
部分加上compileOptions
指定Java版本
android {
// ...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
再锤一次就ok了