Weijia
Weijia

Reputation: 282

[Android]This app won't run unless you update google play services

I implemented a google account sign in button for my app, when I open the app (Android 6.0.1) and enter the sign in page, it shows a dialog saying This app won't run unless you update google play services

This is my code:

compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.google.android.gms:play-services-auth:9.2.1'

public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);

        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .build();
        mGoogleApiClient = new GoogleApiClient.Builder(getActivity().getApplicationContext())
                .addApi(Auth.GOOGLE_SIGN_IN_API)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
        mGoogleApiClient.connect();
    }

I checked the google play services on my android device is 8.1.86 Is that because 8.1<9.2? How to avoid this message for my users who has outdated google play services app?

Upvotes: 0

Views: 705

Answers (1)

Ali
Ali

Reputation: 3221

In order to check Google Play Services you can use int isGooglePlayServicesAvailable (Context) method:

    GoogleApiAvailability.getInstance()
        .isGooglePlayServicesAvailable(context);

If the resultCode = SUCCESS then everything is fine. Otherwise, you decide what to do, if SERVICE_VERSION_UPDATE_REQUIRED you could ask if the user wants to update or you might have other login options.

If you what to show the original dialog call boolean showErrorDialogFragment (Activity activity, int errorCode, int requestCode).

Upvotes: 0

Related Questions