10 September 2010

Importing existing Android projects to Eclipse

When trying to import an existing Android project to Eclipse, I always encounter the error: The method XXXXX must override a superclass method.

At first I was confused. I think this is a Java 1.5 thing, but I am running Java 1.6, and a quick check with my workspace settings show that this is indeed the case. So why the errors?

I searched the intarwebz, and I found out that I am not the only one encountering this! Now I do not want to comment out all the @Override annotations, since it is tedious and would dirty up my code.

Turns out that this is a weird Eclipse behaviour that you can correct with a few simple clicks.


Go to Window > Preferences > Java > Compiler. It should show the compiler compliance level to be 1.6, but the errors are still there. What the frak, Eclipse? Just to be sure, select 1.6 in the dropdown options. This worked for me, but if it doesn't work for you, try the next step.

Click the Configure Project Settings link. It should show a list of the projects in your workspace. Choose your Android project, click OK. Tick the Enable project specific settings box, then choose 1.6 as the compiler compliance level. That should work. :)