在编译我的 libgdx 游戏时,我从 android-studio 收到以下错误:
Error: Default interface methods are only supported starting with
Android N (--min-api 24): com.hgames.core.item.Item
com.hgames.core.item.misc.MiscItem.deepClone()
我不明白,因为我不使用默认接口(interface)方法。我的代码在 JDK1.7 上编译得很好。此处报告的错误涉及以下代码:
interface Item {
Item deepClone()
}
interface MiscItem extends Item {
@Override
MiscItem deepClone()
}
里面没有默认方法。请注意,如果我删除此覆盖,并在调用站点向 MiscItem 添加强制转换,编译器会报告下一个错误(同类错误),因为我在许多地方都使用了此模式。我正在使用 gradle 并在我的 build.gradle 文件中包含以下内容:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
defaultConfig {
minSdkVersion 9
targetSdkVersion 15
compileSdkVersion 15
versionCode 1
}
我是 android-studio 的新手,因为我通常使用 Eclipse,但切换到 android-studio 以将我的游戏移植到 Android。所以也许我遗漏了一些愚蠢的东西,但我在任何地方都找不到任何帮助。
最佳答案
正如 CommonsWare 提到的,作为引用,将此添加到 app 模块 的 build.gradle 中的 android {...} 闭包中以解决问题:
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
...
}
关于android - 错误 : Default interface methods are only supported starting with Nougat (--min-api 24) when NOT using them,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53832815/