简体   繁体   中英

When I fix this Android compiler error, I am getting a multi-catch exception

I am getting Android compiler error like:

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

I am using JDK 1.7. So I changed it to 1.6/1.6.

When I fix it, I get this error:

Multi-catching exception. You need to change it to 1.7. Multi-catch parameters are not allowed for source level below 1.7.

How do I solve this? I want to use multi-catch exceptions...

You want to use multi-catch with Java 1.6 ; you cannot, because it was added in Java 1.7 .

To change the multi-catch blocks you'll need to change every catch of this form (the multi-catch form) -

} catch(ParseException | IOException exception) {
}

to this form (eg standard catch blocks)

} catch (ParseException exception) {
  // do something.
} catch (IOException exception) {
  // do something (else?).
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM