Jinseo Kim
Jinseo Kim

Reputation: 25

Place API Error: Unhandled exceptions

PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
startActivityForResult(builder.build(MainActivity.this), PLACE_PICKER_REQUEST);

I'm using this source code , but there's an error at builder.build(MainActivity.this) like this:

Unhandled exceptions: com.google.android.gms.common.GooglePlayServicesRepairableException, com.google.android.gms.common.GooglePlayServicesNotAvailableException

I checked that it's feature API(compile 'com.google.android.gms:play-services-places:11.4.2' on bulid.gradle). How can I fix it?

Upvotes: 0

Views: 292

Answers (2)

Null Pointer Exception
Null Pointer Exception

Reputation: 1583

This is happend because your play services is not uptodate... below code will show a dialog box to the user for updating Play Services

 Int status;
 @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
        if (status != ConnectionResult.SUCCESS) {
            if (GooglePlayServicesUtil.isUserRecoverableError(status)) {
                GooglePlayServicesUtil.getErrorDialog(status, this,
                        100).show();
            } 
        }
}

Upvotes: 0

Thecave3
Thecave3

Reputation: 797

Just enable/update/upgrade google play services on your phone.

As it is written in official documentation the best solution on production phase is:

GooglePlayServicesRepairableExceptions are special instances of UserRecoverableExceptions which are thrown when Google Play Services is not installed, up-to-date, or enabled. In these cases, client code can use getConnectionStatusCode() in conjunction with getErrorDialog(android.app.Activity, int, int) to provide users with a localized Dialog that will allow users to install, update, or otherwise enable Google Play services.

Upvotes: 1

Related Questions