user3068917
user3068917

Reputation:

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...

Upvotes: 1

Views: 3020

Answers (1)

Elliott Frisch
Elliott Frisch

Reputation: 201507

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 (e.g. standard catch blocks)

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

Upvotes: 2

Related Questions