Rare Nullpointerexception In Googleapiclient Using Firebase
I am using GoogleApiClient to login users using their Google account. Basically, I am using Firebase Auth with Google sign in. But I am getting this crash on some devices every sin
Solution 1:
Hello You can try this code this is a working code in my project first initialize google api client in on create
publicvoidinitGPlus() {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this/* FragmentActivity */, this/* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
}
and on the button click call another function
IntentsignInIntent= Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
In On Activity result just got your response and handle that result in a function
if (requestCode == RC_SIGN_IN) {
GoogleSignInResultresult= Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
}
implement this interface in your activity
implementsGoogleApiClient.OnConnectionFailedListener
Solution 2:
While checking for Google Play services would be good, I think this may be due to a device having an old version of Google Play services.but that's not a great error regardless.
Post a Comment for "Rare Nullpointerexception In Googleapiclient Using Firebase"