App crash onActivityResult GoogleSignInApi
It is the library that i used:
compile 'com.google.android.gms:play-services-auth:9.0.0'
Here is the code for sign in
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
And here the code onActivityResult
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
if (resultCode == RESULT_OK) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
} else {
showSignInFailedMessage();
}
}
}
Stack trace:
Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.myapp/com.myapp.activity.LoginActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=0, data=null} to activity {com.myapp/com.myapp.activity.LoginActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2583)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2097)
at android.app.ActivityThread.access$600(ActivityThread.java:133)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4810)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=0, data=null} to activity {com.myapp/com.myapp.activity.LoginActivity}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:3149)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2570)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2097)
at android.app.ActivityThread.access$600(ActivityThread.java:133)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4810)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.NullPointerException
at com.google.android.gms.internal.zznu.onCreate(Unknown Source)
at com.google.android.gms.internal.zzpc.zza(Unknown Source)
at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:176)
at com.myapp.activity.BaseActivity.onActivityResult(BaseActivity.java:40)
at com.myapp.activity.LoginActivity.onActivityResult(LoginActivity.java:165)
at android.app.Activity.dispatchActivityResult(Activity.java:5192)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3145)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2570)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2097)
at android.app.ActivityThread.access$600(ActivityThread.java:133)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4810)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(NativeStart.java)

+1
+1
Can anyone reliably reproduce this bug? I would be happy to investigate further if there is a way to make it happen, but right now I don't have much to go on.
Similar me
@samtstern I got the error from Crashlytics dashboard, and it is from my users. I don't know how to reproduce the bug reliably :(
I got same issue on Xiaomi Mi 3w os is 6.0.1 but i got issue because i didnt check resultCode == RESULT_OK
@manthan5493 It still happens too even we check for RESULT_OK. This is the code snippet from my onActivityResult
if (requestCode == RC_SIGN_IN) {
if (resultCode == RESULT_OK) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
} else {
CustomLogger.showLog(this, "Result from on activity result is not ok " + resultCode);
showSignInFailedMessage();
}
}
I got same issue too from my users: Android 5.0 on Xiaomi Mi 4i (ferrari) Android 5.1 on Xiaomi Mi 4c (libra)
Library that I used:
compile 'com.google.android.gms:play-services-auth:9.0.2'
Any solutions?
@indraazimi @manthan5493 this seems to be isolated to Xiaomi devices (I don't think it's a coincidence). Does either of you know if there are any particular modifications common to those devices? Are those users in China? I don't have any Xiaomi devices handy.
It happens in samsung devices as well
@olx-gaurav-mishra are you able to reproduce this? If so that would be extremely helpful, we need to capture some additional logs.
As for the Xiaomi devices, it appears to me after some research that Xiaomi devices don't support Google Play Services natively and Play Services must be side loaded. If that's the case, I would not be surprised to see this and other strange failures happening.
Well its not reproducible directly....you can only find crashes on crashlytics.....:-(
This deliverResults flavor of issues (many very similar but slightly different crashes) is by far the main reason for crashes on our apps in Crashlytics. It seems to be related to old versions of the Google Play Services on the user's devices. It happens a lot every time we update the Google Play Services dependency and it gradually reduces over time. It is probably also related to using GoogleApiClient::enableAutoManage() and it indeed occurs on many devices not just Xiaomi. It also does not depend on the user's location since we are seeing it a lot for users currently in Spain. Additionally, this kind of crashes did not occur some months ago, but i am not sure if it only affects newer Google Play Services versions or if it started to occur due to switching from manual handling to the enableAutoManage() calls.
+1
Some of my users are also experiencing the same issue. For my users it happens for Xaiomi devices. Mi 4i (Android version 5.0.2) - 57% Redmi Note 3 (Android version 5.1.1) - 29% MI MAX (Android version 6.0.1) - 14 % Any fix?
@imidhuntv thanks for the additional reports. Since Xiaomi devices do not natively support Google Play Services I don't believe there's anything we can do for those users. It's hard to know what version of Play Services they are running and if they got the APK from a trusted source.
If anyone can reproduce this on a non-Xiaomi device that would be hugely valuable to investigating.
I removed enable auto manage and the crashes have reduced a lot...now it is crashing very less
@olx-gaurav-mishra Thanks for confirming that!
With respect to the affected devices, just by looking at a few of the crashes related to this i see at least several Samsung, LG and Huawei devices, although few of them seem to be the latest devices from these manufacturers. Still some of them are popular devices like the S6, and there are surely more devices on the remaining issues i have in Crashlytics since they are so many due to small differences like line number offsets on the platform classes through the Android versions.
It seems to me that it may be possible to at least stop sending those "results" mentioned in the crashes if they are being sent by the auto manage features of Google Play services, by doing some null checks before sending them.
@olx-gaurav-mishra that's very interesting. I will mention that to the team as well, see if that gives them any hint as to where to look.
Also would you mind sharing the code of the Activity you were using with enableAutoManage?
@olx-gaurav-mishra how do you implement signin without enableAutoManage?