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)
JDK7 is not compatible with android so work with JDK6
String in switch was introduced in JDK7, so it will give an error in JDK6. You have to use either an enum or if-elseif-else.
So, change Java Compiler to JDK6.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With