java Android:重建现在需要编译器合规性级别 5.0 或 6.0。而是找到了“1.7”。为什么要删除@Override?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10162265/
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
Android: rebuild now requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Why remove of @Override?
提问by Purplemonkey
Possible Duplicate:
Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties
可能重复:
Android 要求编译器合规性级别为 5.0 或 6.0。而是找到了“1.7”。请使用 Android 工具 > 修复项目属性
After rebuilding my PC I get this error on importing my projects.
重建我的 PC 后,我在导入我的项目时遇到此错误。
Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties.
I have seen this raised on SO and I can fix my projects by doing the Fix Proj, and then removing all my @OVerrides.
我已经在 SO 上看到了这个问题,我可以通过执行 Fix Proj 来修复我的项目,然后删除我所有的 @Overrides。
this question is why do I now require to remove @Overrides? and will this alter my projects in anyway?
这个问题是为什么我现在需要删除@Overrides?这会改变我的项目吗?
cheers
干杯
Edit to add walkthrough information.
编辑以添加演练信息。
I import a project, I get the error shown above. I then do the Android Tools > Fix Project Properties
. This now sets Project>Properties Java Compile to Compiler Compliance Level 1.5
我导入一个项目,出现上面显示的错误。然后我做Android Tools > Fix Project Properties
. 这现在将 Project>Properties Java Compile 设置为 Compiler Compliance Level 1.5
After this I am left with a series of errors within my java files. on this particular project my errors are on
在此之后,我的 java 文件中出现了一系列错误。在这个特定的项目中,我的错误出现在
@Override
public void run() {...
Error marker to left of error read...
错误读取左侧的错误标记...
Multiple markers at this line
- The method run() of type new Runnable(){} must override a superclass
method
- implements java.lang.Runnable.run
the error hover in eclipse suggests I remove the @Override to fix this issue, and if I do remove the @Override it does fix the issue and my project now compiles and runs. Is this incorrect?
eclipse 中的错误悬停表明我删除了@Override 来解决这个问题,如果我删除了@Override,它确实解决了这个问题,我的项目现在可以编译并运行。这不正确吗?
p.s. I just wrote all that up, changed the Java Compliance level to 1.6 and all the override errors went away! Could someone explain (and I totally appreciate this might be totally off topic) why?
ps 我刚刚写了所有这些,将 Java 合规性级别更改为 1.6,所有覆盖错误都消失了!有人可以解释一下(我完全理解这可能完全偏离主题)为什么?
回答by Shankar Agarwal
Dont remove any @overide notation.
不要删除任何@overide 符号。
you must set project compatibility to Java 5.0 or Java 6.0.
您必须将项目兼容性设置为 Java 5.0 或 Java 6.0。
To do that, 2 options:
为此,有 2 个选项:
1) right-click on your project and select "Android Tools -> Fix Project Properties"
(if this din't work, try second option)
1)右键单击您的项目并选择"Android Tools -> Fix Project Properties"
(如果这不起作用,请尝试第二个选项)
2) right-click on your project and select "Properties -> Java Compiler"
, check "Enable project specific settings"and select 1.5 or 1.6 from "Compiler compliance settings"select box.
2) 右键单击您的项目并选择"Properties -> Java Compiler"
,选中“启用项目特定设置”并从“编译器合规性设置”选择框中选择 1.5 或 1.6 。
refer this LINKfor reference
参考此链接以供参考
回答by Roger Large
FIRST UPDATE EVERYTHING....
第一次更新一切......
Now right click on your project and select "Android Tools" then "Add Support library" it will update then try the stuff i copied from above....
现在右键单击您的项目并选择“Android 工具”,然后选择“添加支持库”它会更新然后尝试我从上面复制的东西....
1) right-click on your project and select "Android Tools -> Fix Project Properties" (if this din't work, try second option)
1) 右键单击您的项目并选择“Android 工具 -> 修复项目属性”(如果这不起作用,请尝试第二个选项)
2) right-click on your project and select "Properties -> Java Compiler", check "Enable project specific settings" and select 1.5 or 1.6 from "Compiler compliance settings" select box.
2) 右键单击您的项目并选择“属性 -> Java 编译器”,选中“启用项目特定设置”并从“编译器合规性设置”选择框中选择 1.5 或 1.6。
Big Thanks to Agarwal Shankar for the start...
非常感谢 Agarwal Shankar 的开始......