Java 使用 1.7 需要用 Android 4.4 (KitKat) 编译;当前使用 API 14
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24639136/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 14
提问by user3810543
So i recently switched the target of my android project to 4.0. Now i have practically errors on every line and the error "Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 14" on the console. So my question is, how do i change this to work with api 14 and compile? thanks.
所以我最近将我的 android 项目的目标切换到 4.0。现在我几乎在每一行上都有错误,并且控制台上的错误“使用 1.7 需要使用 Android 4.4 (KitKat) 进行编译;当前使用 API 14”。所以我的问题是,我如何更改它以使用 api 14 并进行编译?谢谢。
采纳答案by user3810543
If you're supporting API levels < 19 (4.4)
如果您支持 API 级别 < 19 (4.4)
In eclipse: Right click your project -> properties -> from the side bar, pick "Java Compiler" and then change Compiler compliance level to 1.6
在 Eclipse 中:右键单击您的项目 -> 属性 -> 从侧栏中选择“Java 编译器”,然后将编译器合规性级别更改为 1.6
If you're support API levels >= 19
如果您支持 API 级别 >= 19
You shouldn't see this issue. If you do, make sure that your project's minSdkVersion
is properly configured.
你不应该看到这个问题。如果这样做,请确保您的项目minSdkVersion
配置正确。
回答by Justin
I disagree with @Eran, this error cause by setting Project build target
to 4.0 (API 14). If change to Java 1.6, you'll can't use Java 1.7 sode style, for ex: ArrayList myArrayList = new ArrayList<>();
.
To fix this, set your target to 4.4 (API 19) or higher.
我不同意@Eran,这个错误是由设置Project build target
为 4.0 (API 14) 引起的。如果更改为 Java 1.6,您将无法使用 Java 1.7 sode 样式,例如:ArrayList myArrayList = new ArrayList<>();
.
要解决此问题,请将目标设置为 4.4 (API 19) 或更高版本。
回答by user3116317
Below steps solved error in my Eclipse project
以下步骤解决了我的 Eclipse 项目中的错误
- Go to android project
- right click on the project
- select properties
- There is a option named 'Android' in right side menu
- Select higher level API then API 14 or any other API that's installed in you SDK manager
- 进入安卓项目
- 右键单击项目
- 选择属性
- 右侧菜单中有一个名为“Android”的选项
- 选择更高级别的 API,然后选择 API 14 或安装在您的 SDK 管理器中的任何其他 API
and you're done.
你就完成了。