Switch error. Eclipse IDE for Android Development on Mac: Changing Workspace Matching JRE 1.7

When I try to use Case Switch with the key (string) for the android project, I get an error message in the eclipse IDE: Changing the correspondence of the workspace JRE1.7

It is not possible to include a value of type String for the source level below 1.7. Only convertible int values ​​or enum constants are allowed

When I change the project properties to 1.7, I get another error:

Android requires a compiler compliance level of 5.0 or 6.0. Instead, "1.7" was found. Use Android Tools> Fix Project Properties

I do not want to change all these configuration lines in ENUMS. Do I have another option?

My environment: Eclipse SDK, Version: 3.7.2, Build type: M20120208-0800 OS: Mac SnowLeopard (10.6.8)

+6
source share
1 answer

JDK7 not compatible with android, so work with JDK6

String in switch was introduced in JDK7, so it will give an error in JDK6 . You must use either enum or if-elseif-else .

So, change the Java Compiler to JDK6 .

+11
source

Source: https://habr.com/ru/post/912580/


All Articles