Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch Case error. Eclipse IDE for Android development on Mac : Change workspace compliance to JRE 1.7

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)

like image 279
Vikas Singh Avatar asked Apr 06 '12 09:04

Vikas Singh


1 Answers

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.

like image 112
Samir Mangroliya Avatar answered Nov 07 '22 09:11

Samir Mangroliya