开发者

Android @Overrride works on one machine but not another

开发者 https://www.devze.com 2023-04-06 06:53 出处:网络
I have a weird issue. On my Pc i have an android application with @Override used in several places. when i copy the same project on to my laptop at each @Overridei get an error.

I have a weird issue.

On my Pc i have an android application with @Override used in several places. when i copy the same project on to my laptop at each @Overridei get an error.

The method must override a superclass method. How does it work on one machine and not the other?

@Override
public boole开发者_如何转开发an OnMenuItemClick(Menu Item){
}


Most probably your compiler compliance level is set to 1.5 and should be set to 1.6. Go to Window -> Preferences -> Java -> Compiler and check that compliance level is set to 1.6. Also check project specific settings, right click the project and select Properties -> Java compiler. Select 1.6 if project specific settings are enabled.

Clean project and try again.


try to go to Window -> Preferences -> Java -> Compiler -> Errors/Warnings, find your case (about overriding) and choose "Ignore" from the drop down menu on your laptop

maybe there is some configuration that is showing that error


Do you have the same versions of the Java SDK, Android SDK and libraries on both machine? You could be overriding a method that hasn't yet been implemented on your PC's version of Java or Android or other library.


The annotation @Override

Indicates that a method declaration is intended to override a method declaration in a superclass. If a method is annotated with this annotation type but does not override a superclass method, compilers are required to generate an error message.

In addition, from version 1.6 this annotation is used also for methods that are implemented for interface.

Probably you have different version of SKD, on machines, that why the errors are displayed. Instead of removing the warning, you should revise your code and find out what is missing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号