android学习—— Android导入源代码出现Remove @Override问题解决方法 .
来源:互联网 发布:idea设置网络 编辑:程序博客网 时间:2024/06/10 04:04
这个一般是因为配置文件中的JDK版本不对导致的 配置文件就是工程目录下.settings文件夹中org.eclipse.jdt.core.prefs文件
我们如果用UEdit或记事本打开他可以看到里面的代码是这样的
可以看到这里的配置是JDK1.5 我们如果手动将这里的1.5都修改成1.6 然后Refresh下项目就可以了
还有个方法就是 看下面的图吧
这样有些情况可以解决 有时候不行 然后继续下面的操作
改成1.6 然后保存
问题应该都解决了
Eclipse里import 一个可运行的 project经常遇到的一个问题:报一大堆错,当解决了引入jar包、sdk问题后,发现好多error都有一个共同的要求:“remove @Override Annotation”。
How to get rid of all these "remove @Override Annotation" errors?
Is there a way to just comment out all the @Overrides that turn out to be Eclipse errors that prevent your app from building/running?
Solutions:
(1)思路一:There are already @Override annotations in the source code, now I am getting compile errors on them. www.2cto.com
不是SDK的问题(SDK引入正确,排除),难道是JDK?
project上右击-->Properties-->Java Compiler, 显示当前我的Compiler compliance level为1.5,修改为1.6,警报解除。
问题1:我明明安装的jdk1.7,compiler compliance level为什么是1.5呢?
compiler compliance level的含义说明:设置编译级别。
Eclipse compiler compliance level为较低版本,只是让编译器相信你的代码是兼容较低版本的,在编译时生成的bytecode(class)兼容较低版本。这样设置与你写代码时引用的JDK是没关系的,也就是说你在写代码时仍可以引用较高版本的API(这样就可能导致错误)。
设置compiler compliance level为较低版本,这样的好处是当别人使用了较低版本的Jdk时也可以引用你写的编译后的代码。它可以保证编译后的class文件的版本一致性。但是,如果你的代码里面(java source)里面调用了较高版本jdk的API.那么即使设置了compiler compliance level为较低版本,在较低版本的JDK上运行你的代码也会报错。所以建议在写代码时引用的JDK,要跟你compiler compliance level设置的版本,是一致。
问题2:为什么修改为1.6就不再警报了呢?
You need at least jdk1.5 to use those annotations on methods derived from classes.
You need at least jdk1.6 to use those annotations on methods derived from interfaces.
(2)思路二:修改Eclipse警报级别
Window-->Preferences-->Java-->Compiler-->Errors/Warnings-->Annotations
Under there, check that the"Missing '@Override' annotation is set to "Ignore" or "Warning" and not "Error"。
Edit:I wanted to add that you can get Eclipse to automatically add @Override annotations on files that you save in the Save Actions。
Window-->Preferences-->Java-->Editor-->Save Actions
There is a checkbox for "Additional Actions" and if you open the "Configure" window you can select the "Missing Code" tab and select "Add Missing Annotations" where you can select which annotations to automatically add.
(3)思路三:查找-->替换,其实只要remove @Override Annotation就可以
Ctrl+H to bring up the Search dialog
Go to the "File Search" tab.
Enter "@Override" in "Containing text" and "*.java" in "File name patterns".
Click "Replace...", then "OK", to remove all instances of "@Override".
- android学习—— Android导入源代码出现Remove @Override问题解决方法
- android学习—— Android导入源代码出现Remove @Override问题解决方法 .
- 往android - Eclipse中导入新项目时,出现Remove @Override annotation错误提示
- 往android - Eclipse中导入新项目时,出现Remove @Override annotation错误提示
- android 源代码导入调试方法
- android 源代码导入调试方法
- android 源代码导入调试方法
- Android项目导入出现问题解决方案
- Android项目导入出现问题解决方案
- Android项目导入出现问题解决方案
- Android项目导入出现问题解决方案
- Android导入到工程后override方法出错
- Android中线程出现的问题解决方法
- Endorsed Standards Override Mechanism机制学习——debug java源代码方法
- Eclipse导入Android工程,出现default与Displaying的问题解决
- 导入android工程问题解决
- 加载android 工程, @Override must override a superclass method 问题解决
- 问题解决:Android : Must Override a Superclass Method
- JNI学习(3)(我是菜鸟)-jstring介绍
- C语言中枚举类型作为函数入参的陷阱
- oracle-timestamp类型处理
- 写得蛮好的linux学习笔记(主要是linux shell命令)
- 如何检查服务器中的响应是JSONAobject还是JSONArray?
- android学习—— Android导入源代码出现Remove @Override问题解决方法 .
- Spring2.5的Autowired
- 我的第一个Air For iOS 小游戏 ---- 《PopMoon》,作一下记录;
- new JSONObject()不执行 不报错 解决方法
- linux学习笔记一——sudo:无法切换为sudoers组ID:不允许的操作
- 微博炉需求分析
- JNI学习(4)(我是菜鸟)-JNI类型签名
- ORACLE中LIKE语句优化
- ASP.NET弹出新窗口,获得返回值