Default interface methods are only supported starting with Android N

运行环境

  • 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了

上一篇:python mysqldb安装


下一篇:浏览器发起请求之后数据包的旅程