6

Possible Duplicate:
Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties

After rebuilding my PC I get this error on importing my projects.

Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties.

I have seen this raised on SO and I can fix my projects by doing the Fix Proj, and then removing all my @OVerrides.

this question is why do I now require to remove @Overrides? and will this alter my projects in anyway?

cheers

Edit to add walkthrough information.

I import a project, I get the error shown above. I then do the Android Tools > Fix Project Properties. This now sets Project>Properties Java Compile to Compiler Compliance Level 1.5

After this I am left with a series of errors within my java files. on this particular project my errors are on

@Override 
public void run() {... 

Error marker to left of error read...

Multiple markers at this line
    - The method run() of type new Runnable(){} must override a superclass 
     method
    - implements java.lang.Runnable.run

the error hover in eclipse suggests I remove the @Override to fix this issue, and if I do remove the @Override it does fix the issue and my project now compiles and runs. Is this incorrect?

p.s. I just wrote all that up, changed the Java Compliance level to 1.6 and all the override errors went away! Could someone explain (and I totally appreciate this might be totally off topic) why?

Community
  • 1
  • 1
Purplemonkey
  • 1,927
  • 3
  • 27
  • 39

2 Answers2

13

Dont remove any @overide notation.

you must set project compatibility to Java 5.0 or Java 6.0.

To do that, 2 options:

1) right-click on your project and select "Android Tools -> Fix Project Properties" (if this din't work, try second option)

2) right-click on your project and select "Properties -> Java Compiler", check "Enable project specific settings" and select 1.5 or 1.6 from "Compiler compliance settings" select box.

refer this LINK for reference

Lavekush Agrawal
  • 6,040
  • 7
  • 52
  • 85
Shankar Agarwal
  • 34,573
  • 7
  • 66
  • 64
  • thanks. I added some more detail, and you will note I fixed my project overrides by setting java compliance to 1.6. Although I'm not sure why. if you have the inclination I would appreciate an explanation. – Purplemonkey Apr 15 '12 at 14:02
  • Refer this http://android-codes-examples.blogspot.in/2011/03/how-to-run-runnable-thread-or-ui-thread.html – Shankar Agarwal Apr 15 '12 at 14:05
  • -1 why ? because @ovveride introduced later on java1.5... – Samir Mangroliya Apr 23 '12 at 14:51
  • ya but he was having compiler compliance problem not @overide – Shankar Agarwal Apr 23 '12 at 14:55
  • 1
    @Purplemonkey, it's been a long time so maybe you've found the answer to this by now, but the reason why changing the compliance level to 1.6 fixed your problem is because Java 5 only allows `@Override` to be used on overrides of superclass methods, *not* implementations of interface methods. Java 6 allows it to be used on interface methods as well, such as the `run()` method in a class that implements `Runnable`. – Wyzard Nov 11 '13 at 09:02
1

FIRST UPDATE EVERYTHING....

Now right click on your project and select "Android Tools" then "Add Support library" it will update then try the stuff i copied from above....

1) right-click on your project and select "Android Tools -> Fix Project Properties" (if this din't work, try second option)

2) right-click on your project and select "Properties -> Java Compiler", check "Enable project specific settings" and select 1.5 or 1.6 from "Compiler compliance settings" select box.

Big Thanks to Agarwal Shankar for the start...

Roger Large
  • 105
  • 12