I have an Android project completely fine, then I created a separate workspace and imported that project in it. In this new workspace Eclipse shows me several similar issues and advice to remove the @Override annotations for some methods like:
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
I checked project’s properties, JREs and Android APIs – everything is similar.
I tried to clean the project, this didn’t help.
Eclipse’s error description:
The method onClick(View) of type new View.OnClickListener(){} must override a
superclass method Ovals.java /FlyingOvals/src/com/g/g line 38 Java Problem
Why can it be and where should I look to fix these issues?
Check your Java compliance level in the new workspace. In Java 5, @Override was not allowed when implementing methods from an interface. In Java 6, this was allowed. Eclipse will flag a code style warning for this case if it is applicable. You can either set Java compliance level to Java 5 (ideally in the project, so that the settings persist) or you can selectively disable this warning all together for the project.
See Project Properties -> Java Compiler
See Project Properties -> Java Compiler -> Errors Warnings.
I should add that the use of @Override annotation is generally recommended as it will alert you when a base class changes. Consider class Foo with method abc() and a derived class Bar that overrides that method. If you tag abc() method in Bar with @Override, when someone renames abc() method in Foo, you will get alerted as Bar.abc() is no longer overriding anything as it is declaring.