When trying to use a Switch Case with switch(string) for an android project , i get an error in eclipse IDE saying: Change workspace compliance to JRE1.7
Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum constants are permitted
When I change the project properties to 1.7, I get different error saying :
Android requires compiler compliance level 5.0 or 6.0. Found ‘1.7’ instead. Please use Android Tools > Fix Project Properties
I dont want to change all those configuration strings to ENUMS. Do I have any other option?
My environment :
Eclipse SDK, Version: 3.7.2, Build id: M20120208-0800
OS : Mac SnowLeopard (10.6.8)
JDK7is not compatible with android so work withJDK6Stringinswitchwas introduced in JDK7, so it will give an error inJDK6. You have to use either anenumorif-elseif-else.So, change Java Compiler to
JDK6.