Why can't I use Override annotations on Android?

I am developing an Android application, but I cannot use Override annotations. He goes on to say that a method should override a superclass method that does. I am using Java 1.7 and Android API 8 (2.2). Using Eclipse.

Any ideas?

EDIT:

Example

@Override public int getCount() { // TODO Auto-generated method stub return this.data.size(); } 

But the compiler does not allow me to use @Override, saying that this is not a superclass method. I am expanding the BaseAdapter.

+4
source share
2 answers

You must use java 1.6 when creating Android projects. Java 1.7 is not compatible with the current Android toolkit. Change your projects to use 1.6, and this problem should disappear.

In eclipse: Right-click project -> Properties -> Java Compiler -> switches all links to 1.7 to 1.6

+7
source

You can use the @Override annotation. If you get this error, it means that you have an error in the prototype of the method, or you are not expanding what you want to expand.

For example, at API level 8 below, you will get an error like the method introduced in API 11:

 @Override public void startActivities (Intent[] intents){ } 
+2
source

Source: https://habr.com/ru/post/1401382/


All Articles