Android firebase connectivity showing error

Viewed 60

My android application is connected with firebase. It is working fine in another system. For me it showing the error.

GoogleApiAvailability: GMS core API Availability. ConnectionResult=0, tag=null

I tried several method but it showing this error. My code is shown below.

int result = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this);
GoogleApiAvailability.getInstance().showErrorNotification(this, result);
String msg = GoogleApiAvailability.getInstance().getErrorString(result);

It showing the error in third line.

1 Answers

Instead of this code you can use this:

public boolean checkGoogleServices(){
    boolean isAvailable = false;
    Log.d(TAG, "isServicesOk: checking google services version");
    int available = 
GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(Home.this);

    if (available == ConnectionResult.SUCCESS){
        isAvailable = true;
        Log.d(TAG, "isServicesOk: Google Play Services is working");
        Toast.makeText(Home.this, "OK", Toast.LENGTH_LONG).show();
    }
    else if(GoogleApiAvailability.getInstance().isUserResolvableError(available)){

        Log.d(TAG, "isServicesOk: an error occured but we can fix it");
        Dialog dialog = GoogleApiAvailability.getInstance().getErrorDialog(Home.this, available, ERROR_DIALOG_REQUEST);
        dialog.show();
    }else{
        Toast.makeText(Home.this, "You can't make maps request", Toast.LENGTH_LONG).show();
    }
    return isAvailable;
}
Related