After updating Google Play Services to version 18, seems that GooglePlayServicesNotAvailableException can't be used anymore. This piece of code:
try {
MapsInitializer.initialize(ctx);
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
generates this error:
Unreachable catch block for GooglePlayServicesNotAvailableException. This exception is never thrown from the try statement body
How can I achieve the same result now? Thanks
Now the function initialize()
returns a ConnectionResult
so you can do something like this:
if (MapsInitializer.initialize(ctx) != ConnectionResult.SUCCESS) {
// Handle the error
}
来源:https://stackoverflow.com/questions/24969600/google-maps-android-api-v2-googleplayservicesnotavailableexception-not-thrown-a