There is a common issue in Eclipse when importing Android code that sets the default JDK compiler level to 1.5 which causes errors to be reported on all @OverRide annotations in the source. Here is what I found by looking at the change in the file system when importing the ABS library and setting the JDK Compiler level through the menus/dialogs in Eclipse. I imagine this will be the same in the main Android app project as well, but I can further test if you think it would help.
- The ABS library doesn't import via the Android menu, so I used the General menu.
- When importing into Eclipse, a few files are created (below). The default compiler level is set in the creation of one of these files (more on that later)
.project
.classpath
.settings/org.eclipse.jdt.core.prefs
- When I open the dialog (via right-click, Project, Java Compiler) and set the compiler compliance level from 1.5 to 1.6, only one of these file's content is updated
.settings/org.eclipse.jdt.core.prefs
Was (when created by Eclipse):
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.source=1.5
Is (after editing Java compiler compliance level):
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
Solution?
I copied the .settings folder that was created for the ABS library and pasted it into my app's project directory, and when I imported it via Android Existing Code for the first time, the correct compliance level was set and I had no errors.
My system:
Windows 7 x64
Eclipse SDK
Version: 4.2.0 (Juno)
Build id: I20120608-1400
Android tools (ADT plugin for Eclipse, and all the things it comes with)
Version: 20.0.0v201206242043-391819