Search code examples
androideclipseimportworkspace

Problems importing an Android project into Eclipse


I reinstalled my computer and tried now to import my Android project into the workspace. (File -> Import -> General -> Existing Project into Workspace)

But now I have got a strange error.

    bNormal.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            gotoNextQuestion();
        }
    });

In the second line (@Override) eclipse always tells me there is an error:

/* Multiple markers at this line
- implements android.view.View.OnClickListener.onClick
- The method onClick(View) of type new View.OnClickListener(){} must override a superclass Method */

This happens everywhere, where @Override is used. I already tried to Android-Tools -> Fix Project Settings and Project -> Clean.

I hope somebody can help me with this strange problem.

Thanks, Mark


Solution

  • It is because the language level is set to 5.0. Change it to 6, and all will work fine. Don't know where to set it eclipse, but in Idea it's File - Project Structure - Project Language level

    It happens because OnClickListener is an interface and in 5th Java @Override can not be applied to a method implementation.