1、错误信息
升级完 Android N 后,有些项目运行起来报错信息大致如下:
Default interface methods are only supported starting with Android N (--min-api 24):
void android.arch.lifecycle.DefaultLifecycleObserver.onCreate(android.arch.lifecycle.LifecycleOwner) Message{kind=ERROR, text=Default interface methods are only supported starting with Android N (--min-api 24):
void android.arch.lifecycle.DefaultLifecycleObserver.onCreate(android.arch.lifecycle.LifecycleOwner),
sources=[Unknown source file], tool name=Optional.of(D8)}
2、解决方法
在 app 下的 build.gradle 文件 android 界面点加入:compileOptions
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
...
}
8、D8: Default interface methods are only supported starting with Android N (--min-api 24): void