google-services: 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)

screen shot 2016-06-21 at 3 01 06 pm

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 22
  • Comments: 109 (9 by maintainers)

Most upvoted comments

+1

Hi, another stack trace for <compile ‘com.google.android.gms:play-services-auth:10.0.0’>:

java.lang.RuntimeException: Unable to resume activity {my.app.package/my.app.package.android.Login}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=0, data=null} to activity {my.app.package/my.app.package.android.Login}: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.google.android.gms.common.ConnectionResult.getErrorCode()' on a null object reference at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3050) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3081) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2447) at android.app.ActivityThread.access$800(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:211) at android.app.ActivityThread.main(ActivityThread.java:5371) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:945) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:740) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=0, data=null} to activity {my.app.package/my.app.package.android.Login}: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.google.android.gms.common.ConnectionResult.getErrorCode()' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:3680) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3036) ... 11 more Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.google.android.gms.common.ConnectionResult.getErrorCode()' on a null object reference at com.google.android.gms.internal.zzzw.onActivityResult(Unknown Source) at com.google.android.gms.internal.zzabm.onActivityResult(Unknown Source) at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:167) at my.app.package.android.Login.onActivityResult(Login.java:1728) at android.app.Activity.dispatchActivityResult(Activity.java:6192) at android.app.ActivityThread.deliverResults(ActivityThread.java:3676) ... 12 more

I can not reproduce it directly but i have observed a few more things that may help.

Firstly, it is not specific to the sign-in apis. I have an app that only uses the app invite and the location apis (but not sign-in) and it happens there too.

Secondly, some of the related crashes can be catched by surrounding the call to super.onActivityResult(requestCode, resultCode, data) with a try-catch. If i report the issues occurring there as non-fatals i get slighty different stack traces like this (i have renamed the line mentioning my actual activity and source file to not reference the affected apps):

Non-fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.google.android.gms.common.ConnectionResult.c()' on a null object reference
       at com.google.android.gms.internal.zzqd.onCreate(Unknown Source)
       at com.google.android.gms.internal.zzrn.onActivityResult(Unknown Source)
       at android.support.v4.app.FragmentActivity.onActivityResult(SourceFile:165)
       at MyActivity.onActivityResult(SourceFile:Line)
       at android.app.Activity.dispatchActivityResult(Activity.java:6320)
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3836)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3223)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3268)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2517)
       at android.app.ActivityThread.access$1200(ActivityThread.java:165)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5593)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

No other code from my activity is executed when this second flavor of exceptions occurs besides calling super.onActivityResult().

Finally, i have a feeling that this crashes are not repeating continuously because users very rarely complain about crashes on the app ratings. It may be that it only occurs the first time the Google Play Services check is performed or that it occurs on a background thread and it is not noticeable. But i definitely would expect more users complaining and it is not the case. Do the other developers here also have the same experience with this?

Hope any of this helps to narrow the issues a bit!

@samtstern I got the error from Crashlytics dashboard, and it is from my users. I don’t know how to reproduce the bug reliably 😦

@mobiRic (or anyone seeing this crash), we’ve got a potential fix that landed in 9.8.0, have you had a chance to release that version of your app and see if the crashes are still happening? Thanks.

@hendrawd I am using GoogleSignInClient’s getSignInIntent method it don’t have any parameter.

I think u hare talking about Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient)

I also get the null Intent data onActivityResult() during Sign In.

Device Intex Aqua 4G Strong used by a customer in India Play services 10.2.0

Below is a badly formatted stack trace 😕

`Exception java.lang.RuntimeException: Unable to resume activity {com.softwyer.collections.storage/com.softwyer.collections.core.SignInActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=0, data=null} to activity {com.softwyer.collections.storage/com.softwyer.collections.core.SignInActivity}: java.lang.NullPointerException: Attempt to invoke virtual method ‘int com.google.android.gms.common.ConnectionResult.c()’ on a null object reference android.app.ActivityThread.performResumeActivity (ActivityThread.java:3245) android.app.ActivityThread.handleResumeActivity (ActivityThread.java:3276) android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2619) android.app.ActivityThread.access$800 (ActivityThread.java:178) android.app.ActivityThread$H.handleMessage (ActivityThread.java:1470) android.os.Handler.dispatchMessage (Handler.java:111) android.os.Looper.loop (Looper.java:194) android.app.ActivityThread.main (ActivityThread.java:5643) java.lang.reflect.Method.invoke (Method.java) java.lang.reflect.Method.invoke (Method.java:372) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:960) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:755)

Caused by java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=0, data=null} to activity {com.softwyer.collections.storage/com.softwyer.collections.core.SignInActivity}: java.lang.NullPointerException: Attempt to invoke virtual method ‘int com.google.android.gms.common.ConnectionResult.c()’ on a null object reference android.app.ActivityThread.deliverResults (ActivityThread.java:3845) android.app.ActivityThread.performResumeActivity (ActivityThread.java:3227) android.app.ActivityThread.handleResumeActivity (ActivityThread.java:3276) android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2619) android.app.ActivityThread.access$800 (ActivityThread.java:178) android.app.ActivityThread$H.handleMessage (ActivityThread.java:1470) android.os.Handler.dispatchMessage (Handler.java:111) android.os.Looper.loop (Looper.java:194) android.app.ActivityThread.main (ActivityThread.java:5643) java.lang.reflect.Method.invoke (Method.java) java.lang.reflect.Method.invoke (Method.java:372) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:960) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:755)

Caused by java.lang.NullPointerException: Attempt to invoke virtual method ‘int com.google.android.gms.common.ConnectionResult.c()’ on a null object reference com.google.android.gms.internal.zzaae.onCreate (zzaae.java) <OR>.onStart (zzaae.java) <OR>.onActivityResult (zzaae.java) <OR>.zza (zzaae.java) <OR>.zza (zzaae.java) com.google.android.gms.internal.zzabu.onActivityResult (zzabu.java) android.support.v4.app.FragmentActivity.onActivityResult (FragmentActivity.java:164) com.softwyer.collections.core.SignInActivity.onActivityResult (SignInActivity.java:155) android.app.Activity.dispatchActivityResult (Activity.java:6302) android.app.ActivityThread.deliverResults (ActivityThread.java:3841) android.app.ActivityThread.performResumeActivity (ActivityThread.java:3227) android.app.ActivityThread.handleResumeActivity (ActivityThread.java:3276) android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2619) android.app.ActivityThread.access$800 (ActivityThread.java:178) android.app.ActivityThread$H.handleMessage (ActivityThread.java:1470) android.os.Handler.dispatchMessage (Handler.java:111) android.os.Looper.loop (Looper.java:194) android.app.ActivityThread.main (ActivityThread.java:5643) java.lang.reflect.Method.invoke (Method.java) java.lang.reflect.Method.invoke (Method.java:372) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:960) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:755)`

I’m actually seeing the null intent data onActivityResult for all KitKat devices consistently (every time). This happens both for Google Sign In as well as for the SmartLock Credentials callback.

Using compile ‘com.google.android.gms:play-services-auth:9.8.0’ and tried compile ‘com.google.android.gms:play-services-auth:10.0.1’

I’m getting the same exception with Google Play Services 10.0.1 for users with Xiaomi phones when they try to sign in. Here is the stacktrace in case it helps:

Exception java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1001, result=0, data=null} to activity {io.tinbits.memorigi/io.tinbits.memorigi.activity.WelcomeActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.auth.api.signin.b.b()' on a null object reference
android.app.ActivityThread.deliverResults (ActivityThread.java:3723)
android.app.ActivityThread.handleSendResult (ActivityThread.java:3766)
android.app.ActivityThread.access$1400 (ActivityThread.java:153)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1409)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:5458)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:738)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:628)
arrow_drop_down
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.auth.api.signin.b.b()' on a null object reference
io.tinbits.memorigi.activity.WelcomeActivity.onActivityResult ()
android.app.Activity.dispatchActivityResult (Activity.java:6537)
android.app.ActivityThread.deliverResults (ActivityThread.java:3719)
android.app.ActivityThread.handleSendResult (ActivityThread.java:3766)
android.app.ActivityThread.access$1400 (ActivityThread.java:153)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1409)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:5458)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:738)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:628)

Do we have a workaround besides try-catching super.onActivityResult() call?

We released with v9.8.0 just after the 3rd November, and it is looking promising in our Crashlytics so far. If I see something similar I will return to this thread and provide a v9.8.0 stack trace. Thx

@mobiRic and everyone, please provide your SDK version for us to de-obfuscate your stack trace. Thanks! And if anyone has a bug report, it will also be very helpful!

e.g. compile ‘com.google.android.gms:play-services-auth:9.0.0’

@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.