I’m currently developing a small test project with Android and I get the infamous @Override error:
The method onBackPress() of type KvizActivity must override or implement a
supertype method.
Here is the code that causes it:
public class KvizActivity extends Activity {
/** onCreate(), onDestroy(), etc... */
@Override
public void onBackPress() {
}
}
Now I know what you are thinking: there are tons of such questions and answers to them already. I know, I read all of them, still, I can’t get rid of it. I know the core cause of it is that Eclipse is using JDK 1.5 instead of 1.6 or higher.
But I have done all this: Went to Project -> Properties -> Java Compiler and I set it to 1.6. Error still there.
Then I went to Window -> Preferences -> Java Compiler and set it to 1.6 there, so it would be global, still it persists. Then I set the Project Specific Settings even though I already did this, I retried it. Nothing. I Cleaned the project and used Rebuild but still it is there.
I cant think of anything else to do.
Here is my Java version:
Java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode, sharing)
I have Eclipse 3.7.1 which I believe is the latest.
I hope anybody can shed some light on this.
The method you want to override is
onBackPressed(). For@Overrideto work, the method signature must match the method declared in the parent class. In this case, you misspelled the method name.