App crash onActivityResult GoogleSignInApi #240

Open
hendrawd opened this Issue Jun 21, 2016 · 76 comments

Projects

None yet
@hendrawd
hendrawd commented Jun 21, 2016 edited

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

@hmedat2008

+1

@idanakav

+1

@samtstern
Member

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.

@phantuanphong

Similar me

@hendrawd

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

@manthan5493

I got same issue on Xiaomi Mi 3w os is 6.0.1 but i got issue because i didnt check
resultCode == RESULT_OK

@hendrawd
hendrawd commented Aug 29, 2016 edited

@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();
    }
}
@indraazimi

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?

@samtstern
Member

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

@olx-gaurav-mishra

It happens in samsung devices as well

@samtstern
Member

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

@olx-gaurav-mishra

Well its not reproducible directly....you can only find crashes on crashlytics.....:-(

@jrgonzalezg

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.

@imidhuntv

+1

@imidhuntv
imidhuntv commented Sep 26, 2016 edited

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?

@samtstern
Member

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

@olx-gaurav-mishra

I removed enable auto manage and the crashes have reduced a lot...now it is crashing very less

@jrgonzalezg
jrgonzalezg commented Sep 29, 2016 edited

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

@samtstern
Member

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

@KushGoyal
KushGoyal commented Oct 11, 2016 edited

@olx-gaurav-mishra how do you implement signin without enableAutoManage?

@paisrikanth

+1
I see the same crash logs on my crashlytics.. the device is Samsung

@olx-gaurav-mishra

@KushGoyal u need to remove enableautomanage line from code and start using lifecycle callbacks for activity/fragment to connect disconnect GoogleApiclient. Refer to https://developers.google.com/identity/sign-in/android/sign-in
the highlighted blue section.
I did it by connecting GoogleAPIClient in onStart and disconnecting in onStop

@samtstern
Member

Can anyone in this thread make this happen on a device they own and capture a bugreport after? The Google Sign In team (and the GoogleApiClient authors) are trying to debug this but can't get everything from the stack trace.

@jrgonzalezg
jrgonzalezg commented Oct 19, 2016 edited

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
Member

@jrgonzalezg that's super helpful, thanks for all of that. Will pass it on.

@aaronj1335

@jrgonzalezg yes thank you very much!

What version of the play-services dependencies are you using?

@jrgonzalezg

Great!, i am glad that's useful since it would be very good to see this fixed.

About the version, that stack trace is quite recent so it was using play-services 9.6.1 but it also happened on several previous versions. Also, not all of the errors can be catched there, some of them lead to stack traces more similar to the one posted by @hendrawd that do not go through any of the app code.

@jrgonzalezg
jrgonzalezg commented Oct 19, 2016 edited

Another one with play services 9.4.0:

Non-fatal Exception: java.lang.NullPointerException
       at com.google.android.gms.internal.zzpn.onCreate(Unknown Source)
       at com.google.android.gms.internal.zzqv.onActivityResult(Unknown Source)
       at android.support.v4.app.FragmentActivity.onActivityResult(SourceFile:165)
       at MyActivity.onActivityResult(SourceFile:Line)
       at android.app.Activity.dispatchActivityResult(Activity.java:5423)
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3518)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2870)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2912)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2334)
       at android.app.ActivityThread.access$800(ActivityThread.java:145)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
       at android.os.Handler.dispatchMessage(Handler.java:102)

And a sample of one of the not catchable exceptions (play services 9.6.1):

Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=0, data=null} to activity {MY_APPLICATION_ID/com.google.android.gms.common.api.GoogleApiActivity}: java.lang.NullPointerException
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3162)
       at android.app.ActivityThread.handleSendResult(ActivityThread.java:3205)
       at android.app.ActivityThread.access$1100(ActivityThread.java:138)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:213)
       at android.app.ActivityThread.main(ActivityThread.java:4787)
       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.common.api.GoogleApiActivity.zza(Unknown Source)
       at com.google.android.gms.common.api.GoogleApiActivity.onActivityResult(Unknown Source)
       at android.app.Activity.dispatchActivityResult(Activity.java:5192)
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3158)
       at android.app.ActivityThread.handleSendResult(ActivityThread.java:3205)
       at android.app.ActivityThread.access$1100(ActivityThread.java:138)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:213)
       at android.app.ActivityThread.main(ActivityThread.java:4787)
       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)
@wingjay
wingjay commented Oct 21, 2016 edited

So do we have a way to prevent crash in play service 9.4.0? Thank you.

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.glow.android.eve/com.glow.android.eve.ui.landing.WelcomeActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=0, data=null} to activity {com.glow.android.eve/com.glow.android.eve.ui.landing.WelcomeActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.google.android.gms.common.ConnectionResult.c()' on a null object reference
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3083)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3114)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2445)
       at android.app.ActivityThread.access$800(ActivityThread.java:162)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1348)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5422)
       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:914)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
Caused by java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=0, data=null} to activity {com.glow.android.eve/com.glow.android.eve.ui.landing.WelcomeActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.google.android.gms.common.ConnectionResult.c()' on a null object reference
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3688)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3069)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3114)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2445)
       at android.app.ActivityThread.access$800(ActivityThread.java:162)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1348)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5422)
       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:914)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
Caused by 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.zzpn.onCreate(Unknown Source)
       at com.google.android.gms.internal.zzqv.zza(Unknown Source)
       at android.support.v4.app.FragmentActivity.onActivityResult(SourceFile:175)
       at com.glow.android.trion.base.BaseActivity.onActivityResult(SourceFile:231)
       at com.glow.android.eve.ui.landing.WelcomeActivity.onActivityResult(SourceFile:286)
       at android.app.Activity.dispatchActivityResult(Activity.java:6259)
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3684)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3069)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3114)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2445)
       at android.app.ActivityThread.access$800(ActivityThread.java:162)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1348)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5422)
       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:914)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
@KE7JLM
KE7JLM commented Oct 21, 2016

Its happening constantly on our S4, Note 5 and Nexus 6. All running 9.8.77

Strangely, one S4 works while the other does not, both are identical.

10-21 13:48:47.551 13245-13245/com.gox.smartrun E/UncaughtException: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=9001, result=-1, data=Intent { (has extras) }} to activity {com.gox.smartrun/com.gox.smartrun.login.LoginActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:4053)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4096)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1516)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference
at com.gox.smartrun.login.LoginActivity.handleSignInResult(LoginActivity.java:161)
at com.gox.smartrun.login.LoginActivity.onActivityResult(LoginActivity.java:139)
at android.app.Activity.dispatchActivityResult(Activity.java:6917)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4049)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4096) 
at android.app.ActivityThread.-wrap20(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1516) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6077) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 

@isaisachen

@KE7JLM Your crash is different.

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference
at com.gox.smartrun.login.LoginActivity.handleSignInResult(LoginActivity.java:161)

GoogleSignInAccount.getPhotoUrl returns a Uri object and it can be null.

Javadoc:
Uri getPhotoUrl ()
Returns the photo url of the signed in user if the user has a profile picture and you built your configuration either starting from new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) } or with requestProfile() configured; null otherwise.

@isaisachen

A bug report will be helpful!

And if you can share your GoogleApiClient related code snippet, it might also help (for those use GoogleApiClient. There are 2 usages here, a) APIs like firebase invite b) APIs like Google Sign In API which requires a GoogleApiClient)
a) Do you build GoogleApiClient in onCreate or onStart?
b) Do you call startAutoManage / stopAutoManage? If so, where?
c) Do you have multiple GoogleApiClient in the same Activity?

Thanks for all your help!

@manev15
manev15 commented Oct 23, 2016

anyone got solution for this?

@brendanw

Is there a way we can view the source code in the package com.google.android.gms.internal?

@isaisachen

@brendanw No, it's not open sourced. Google is actively working on this, but without repro step / bug report, it might take a little longer.

@imidhuntv

screen shot 2016-10-28 at 3 24 09 pm

See, All are Xaiomi devices. But in the same devices our testing team couldn't repro this. We were able to signIn without any problem. So this must be happening rarely for some reason.

@niteshgoel

I am also getting the same issue all of a sudden in crashlytics many times on Redmi devices.

Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=9001, result=0, data=null} to activity {com.invitesu.invitation/com.wedding.invitation.LoginActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.auth.api.signin.d.c()' on a null object reference
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3595)
       at android.app.ActivityThread.handleSendResult(ActivityThread.java:3638)
       at android.app.ActivityThread.access$1300(ActivityThread.java:154)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1366)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5290)
       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:911)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.auth.api.signin.d.c()' on a null object reference
       at com.wedding.invitation.social.GPlusUtilNew.handleSignInResult(GPlusUtilNew.java:1113)
       at com.wedding.invitation.LoginActivity.onActivityResult(LoginActivity.java:117)
       at android.app.Activity.dispatchActivityResult(Activity.java:6241)
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3591)
       at android.app.ActivityThread.handleSendResult(ActivityThread.java:3638)
       at android.app.ActivityThread.access$1300(ActivityThread.java:154)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1366)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5290)
       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:911)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)

@mobiRic
mobiRic commented Nov 8, 2016 edited

To add to this issue, I'm getting the same null pointer in the same places, but I'm only using Google Maps.

This is not a Xiaomi problem:

  • 52% Samsung devices
  • 32% Sony
  • 11% LG

As with other posters, we can't replicate it in our office, but are seeing reports on Crashlytics.

We launched with Google Maps in April, and these crashes only started coming in at the beginning of October, just after we upgraded Google Play SDK from v8.4.0 to v9.4.0. We have a v9.8.0 update pending release, but not out in production yet.


Partial stack trace showing same zzpn class as referenced in previous traces:

Caused by java.lang.NullPointerException
       at com.google.android.gms.internal.zzpn.onActivityResult(Unknown Source)
       at com.google.android.gms.internal.zzqv.onActivityResult(Unknown Source)
       at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:165)
@hendrawd
hendrawd commented Nov 9, 2016

@mobiRic from your report maybe the problem started between version 8.4.0 and 9.0.0, because i use version 9.0.0 and the problem exist

@isaisachen

@niteshgoel Need your SDK version to tell, but doesn't look like the same issue.

@isaisachen

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

@isaisachen

@imidhuntv, for your case, it's all Xiaomi, which is an interesting case. Do you distribute your apps only through Play Store? Or you publish it to other app store as well? A bug report can tell everything, but with no bug report, I am curious to know if it happened to:
a) devices without Play Store / Google Play services (e.g. they download your app from other channels)
or
b) devices which users install Play Store / Google Play services by themselves (either via sideloading or e.g. they download "Google Installer" and then install all of Google Services Framework / account manager / Google Play services / Play Store... by themselves

@niteshgoel

@isaisachen my sdk version

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

@olx-gaurav-mishra

@isaisachen compile('com.google.android.gms:play-services-auth:9.4.0')

@mobiRic
mobiRic commented Nov 10, 2016

@isaisachen as I said above, this was for the v9.4.0 frameworks.

@aaronj1335

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

@mobiRic
mobiRic commented Nov 22, 2016

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

@samtstern
Member

@mobiRic thanks for the update! Hope the results stay positive.

@kishorgandham

The issue persists in v9.8.0 and v10.0.0 play services.

@hendrawd

I can confirm that the issue still occuring even though i use version 9.8.0

@hendrawd hendrawd closed this Nov 25, 2016
@hendrawd hendrawd reopened this Nov 25, 2016
@aaronj1335

@hendrawd or @kishorgandham mind sharing a 9.8+ stacktrace?

@kishorgandham
kishorgandham commented Nov 30, 2016 edited

Here is a stack trace I got from Crashlytics. I can't replicate this locally.

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {x.x.x/x.x.x.x.SplashActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=0, data=null} to activity {x.x.x.x/x.x.x.x.SplashActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2581)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2609)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2095)
at android.app.ActivityThread.access$600(ActivityThread.java:136)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4800)
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:798)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:565)
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 {x.x.x/x.x.x.x.activity.SplashActivity}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:3153)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2568)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2609)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2095)
at android.app.ActivityThread.access$600(ActivityThread.java:136)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4800)
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:798)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:565)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.NullPointerException
at com.google.android.gms.internal.zzzw.onCreate(Unknown Source)
at com.google.android.gms.internal.zzabm.onActivityResult(Unknown Source)
at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:165)
at x.x.x.x.SplashActivity.onActivityResult(SplashActivity.java:116)
at android.app.Activity.dispatchActivityResult(Activity.java:5192)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3149)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2568)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2609)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2095)
at android.app.ActivityThread.access$600(ActivityThread.java:136)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4800)
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:798)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:565)
at dalvik.system.NativeStart.main(NativeStart.java)

@hendrawd
hendrawd commented Dec 1, 2016 edited

Hi @aaronj1335 , here is the stacktrace from crashlytics. It happens on version 9.8 actually, i have updated the version to 10.0.0 but haven't update the application to the market.

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {my.app.package/my.app.package.activity.LoginActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=0, data=null} to activity {my.app.package/my.app.package.activity.LoginActivity}: java.lang.NullPointerException
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2788)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2817)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
       at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3738)
       at android.app.ActivityThread.access$900(ActivityThread.java:135)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5021)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)
       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 {my.app.package/my.app.package.activity.LoginActivity}: java.lang.NullPointerException
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3365)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2775)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2817)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
       at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3738)
       at android.app.ActivityThread.access$900(ActivityThread.java:135)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5021)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)
       at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.NullPointerException
       at com.google.android.gms.internal.zzqp.onCreate(Unknown Source)
       at com.google.android.gms.internal.zzsd.zza(Unknown Source)
       at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:167)
       at my.app.package.activity.BaseActivity.onActivityResult(BaseActivity.java:41)
       at my.app.package.activity.LoginActivity.onActivityResult(LoginActivity.java:215)
       at android.app.Activity.dispatchActivityResult(Activity.java:5529)
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3361)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2775)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2817)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
       at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3738)
       at android.app.ActivityThread.access$900(ActivityThread.java:135)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5021)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)
       at dalvik.system.NativeStart.main(NativeStart.java)
@aaronj1335

Thank you!

@EdwardClay

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

@TasneemBohra
TasneemBohra commented Dec 12, 2016 edited

I am getting this in 9.8.0 , I have updated to 10.0.0 but not released the apk yet. And this is being coming after updating to 9.8.0 majorly.

screen shot 2016-12-12 at 1 54 03 pm

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {app.desidime/com.desidime.app.ui.activities.LoginActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=0, data=null} to activity {app.desidime/com.desidime.app.ui.activities.LoginActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2823) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2862) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$600(ActivityThread.java:139) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:156) at android.app.ActivityThread.main(ActivityThread.java:4987) 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:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 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 {app.desidime/com.desidime.app.ui.activities.LoginActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:3398) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2804) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2862) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$600(ActivityThread.java:139) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:156) at android.app.ActivityThread.main(ActivityThread.java:4987) 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:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(NativeStart.java) Caused by java.lang.NullPointerException at com.google.android.gms.internal.zzqp.onCreate(Unknown Source) at com.google.android.gms.internal.zzsd.onActivityResult(Unknown Source) at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:167) at com.desidime.app.ui.activities.LoginActivity.onActivityResult(LoginActivity.java:149) at android.app.Activity.dispatchActivityResult(Activity.java:4747) at android.app.ActivityThread.deliverResults(ActivityThread.java:3394) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2804) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2862) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$600(ActivityThread.java:139) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:156) at android.app.ActivityThread.main(ActivityThread.java:4987) 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:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(NativeStart.java)

And here is my code


 private static final int RC_SIGN_IN = 0;

--------------------------------------------------------

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestScopes(new Scope(Scopes.PLUS_LOGIN))
                .requestEmail()
                .requestIdToken(BuildConfig.GOOGLE_CLIENT_ID)
                .build();

 mGoogleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this, this)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .build();

--------------------------------------------------------------
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
            startActivityForResult(signInIntent, RC_SIGN_IN);

-----------------------------------------------------------------
@Override
    protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
        super.onActivityResult(requestCode, responseCode, intent);
        // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
        try {
            if (requestCode == RC_SIGN_IN) {
                if (responseCode == RESULT_OK) {
                    Log.d(TAG, "onActivityResult: requestcode=sign in");
                    handleGoogleSignIn(Auth.GoogleSignInApi.getSignInResultFromIntent(intent));
                } else {
                    Utils.showSnackBar(mView, getString(R.string.google_account_null_error));
                }
            } else {
                //
            }
        } catch (Exception e) {
            Crashlytics.logException(e);
        }
    }


When I checked on https://console.developers.google.com/apis/api/plus-json.googleapis.com/ , there is no error for this time period.

screen shot 2016-12-12 at 2 08 29 pm

In my case users are complaining that they are not able to login via google.

@rylexr
rylexr commented Dec 22, 2016 edited

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?

@isaisachen

@rylexr Your case seems different:
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

Are you using proguard? b.b() is not part of our SDK proguard mapping. I'm suspecting auth.api.signin.GoogleSignInResult.isSuccess() though. Did you use Auth.GoogleSignInApi.getSignInResultFromIntent to get the GoogleSignInResult?

You mentioned the error happened to Xiaomi devices (only)? Do you think those users have (Google) Play Store?

@rylexr
rylexr commented Jan 3, 2017

@isaisachen Thanks for your comment. Yes, I'm using ProGuard. Here is the mapping I got:

com.google.android.gms.auth.api.signin.GoogleSignInResult -> com.google.android.gms.auth.api.signin.b:
    com.google.android.gms.common.api.Status zzahq -> a
    com.google.android.gms.auth.api.signin.GoogleSignInAccount zzajn -> b
    void <init>(com.google.android.gms.auth.api.signin.GoogleSignInAccount,com.google.android.gms.common.api.Status) -> <init>
    com.google.android.gms.auth.api.signin.GoogleSignInAccount getSignInAccount() -> a
    com.google.android.gms.common.api.Status getStatus() -> getStatus
    boolean isSuccess() -> b

The only rules I have for Google libraries are these:

-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }

-keep public class * extends android.support.v4.view.ActionProvider {
    public <init>(android.content.Context);
}

This is what I got in my "Welcome Activity":

public final class WelcomeActivity extends AppCompatActivity implements
    GoogleApiClient.OnConnectionFailedListener {

  private GoogleApiClient googleApiClient;
  private FirebaseAuth auth;
  private FirebaseAuth.AuthStateListener authListener;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    vb = DataBindingUtil.setContentView(this, R.layout.welcome_activity);
    vb.bSignIn.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        if (googleApiClient != null && googleApiClient.isConnected()) {
          Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleApiClient);
          startActivityForResult(signInIntent, 1001);
        } else {
          showErrorToast(getString(R.string.google_play_services_error));
        }
      }
    });

    buildGoogleApiClient();

    auth = FirebaseAuth.getInstance();
    authListener = new FirebaseAuth.AuthStateListener() {
      @Override
      public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
        FirebaseUser user = firebaseAuth.getCurrentUser();
        if (user != null) {
          successfulSignIn(user);
        }
      }
    };
  }

  @Override
  protected void onStart() {
    super.onStart();
    auth.addAuthStateListener(authListener);
  }

  @Override
  protected void onStop() {
    super.onStop();
    if (authListener != null) {
      auth.removeAuthStateListener(authListener);
    }
  }

  @Override
  public void onConnectionFailed(@NonNull final ConnectionResult connectionResult) {
    LOGD(TAG, "onConnectionFailed");
    showErrorToast(getString(R.string.google_play_services_error));
  }

  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    try { // ***** This is where it fails *****
      super.onActivityResult(requestCode, resultCode, intent);
    } catch (Exception e) {
      LOGE(TAG, "Error calling super onActivityResult(): " + e.getMessage(), e);
      showErrorToast(e.getMessage());
      return;
    }
    switch (requestCode) {
      case 1001:
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(intent);
        if (result.isSuccess()) {
          firebaseAuthWithGoogle(result.getSignInAccount());
        } else if (result.getStatus().getStatusCode() == GoogleSignInStatusCodes.SIGN_IN_CANCELLED) {
          LOGD(TAG, "User cancelled sign in: " + result.getStatus());
        } else {
          LOGD(TAG, "Unknown error on sign in: " + result.getStatus());
          showErrorToast(result.getStatus().getStatusMessage());
        }
        break;
    }
  }

  private void buildGoogleApiClient() {
    GoogleSignInOptions gsio = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestIdToken(getString(R.string.default_web_client_id))
        .requestId()
        .requestEmail()
        .requestProfile()
        .build();

    vb.bSignIn.setSize(SignInButton.SIZE_WIDE);

    googleApiClient = new GoogleApiClient.Builder(this)
        .enableAutoManage(this, this)
        .addApi(Auth.GOOGLE_SIGN_IN_API, gsio)
        .build();
  }

  ...
}

They have Google Play Store and Google Play Services updated to latest version. It seems some Samsung Galaxy users are having the same problem as well. Any ideas?

@isaisachen

@rylexr Thanks for the proguard mapping. It's indeed GoogleSignInResult.isSuccess() call. Basically, NPE from code below:
case 1001:
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(intent);
if (result.isSuccess()) {
...
}

And I looked at your call stack again, you got null Intent data in onActivityResult from Google Sign-In intent, which is not expected (even for error case, SDK should return you an Intent object). While I can look into why SDK return null Intent data, in the meantime, you can add "result != null" check in addition to "result.isSuccess()" to work around this.

@rylexr
rylexr commented Jan 4, 2017

@isaisachen Thanks for the reply. Unfortunately, this doesn't work. I mean, it prevents from crashing but users aren't unable to sign in either way. It's really frustrating to see how people rate your app with 1 star because of this and I can't offer a solution. Is there an ETA about fixing this issue? I know you guys have a lot of work to do but knowing at least you're working on this will give me some relief. Regards.

@isaisachen

@rylexr What's the error rate? This is the very first report of such a symptom. Any chance you can repro or get a bug report? And when you mentioned these users' "Google Play Services updated to latest version", just curious, how could you tell?

@rylexr
rylexr commented Jan 5, 2017

@isaisachen It's enough to keep receiving 1 rate stars every day. Here you can see a crash report from yesterday + 45 more from different users (pretty much everyone with Xiaomi devices).

crash report

I know they have GPS updated because I talked to them and they sent me screenshots of the GPS settings view with its version. Unfortunately, I haven't been able to reproduce it. I think I'll have to spend money on buying a Xiaomi phone and see but this shouldn't be the approach when this kind of problems arises. Any suggestions?

@isaisachen

@rylexr I do have Xiaomi device for testing. Our sample / test apps all work fine on it. Could you share with me (offline) what's your app and I can try to repro on Xiaomi. We do want to solve all reported issues. But sometimes without a repro / bug report, it's difficult for us to track down what's happening. Thank you.

@isaisachen

@rylexr I cannot repro with the app on your profile on Xiaomi device with latest GPS. You can email @samtstern (check out his profile) and we can exchange information offline.

@rylexr
rylexr commented Jan 5, 2017

@isaisachen information sent.

@ankush38u

Firstly I'm having similar stacktrace using services 9.4.0 , here is a stackoverflow which suggest to override startActivityForResult() and catch the exception there by calling super.(http://stackoverflow.com/questions/17549030/android-nullpointerexception-in-instrumentation-execstartactivity)

Another way I found some stackoverflow user suggesting to override startActivityForResult and null check for intent and provide intent if its null like.

@Override
public void startActivityForResult(Intent intent, int requestCode) {
if (intent == null) {
intent = new Intent();
}
super.startActivityForResult(intent, requestCode);
}

if some of you have followed this like me this is not a solution and sends an empty intent instead of one we should get from:
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);

That's the reason behind what crashes the app onActivityResult, The reason behind could be lack of playservices in device.

There are 2 temporary way as workaround(at least until Google do something for us)

  1. Check for RESULTOK and also check GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); this result object should not be null.

  2. like the stackoverflow link suggests, override the startActivityForResult() and catch Exception on super call, here you can display custom message to User.

@kanerogers

Hi, friends!

Any updates here? 😄

@isaisachen
isaisachen commented Jan 17, 2017 edited

@kanerogers There are multiple issues in this thread, including SDK issues and developers' own issues. To-recap SDK issues:

  1. Caused by java.lang.NullPointerException related to GoogleApiActivity - This should be fixed in SDK 10.0+:
    Caused by java.lang.NullPointerException
    at com.google.android.gms.common.api.GoogleApiActivity.zza(Unknown Source)
    at com.google.android.gms.common.api.GoogleApiActivity.onActivityResult(Unknown Source)

  2. NullPointerException for ConnectionResult.getErrorCode() - There's a potential fix in v10.4 later this year. We'll post here when that version is out:
    Caused by 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)
    ...

  3. null Intent data in onActivityResult from Google Sign-In intent - This has only been reported by one developer so far and we are still looking into this.

@isaisachen

@ankush38u Thanks for the feedback!

For below:
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);

This will never return an empty Intent even for devices without Google Play services. But true, when Google Play services is not available, onActivityResult will still get called. In that case, you are supposed to receive INTERNAL_ERROR (error code 8). I cannot repro, but we will try to make error communication more clear for absence of Google Play services case. (in possibly v10.4).

If you can repro somehow, please share with me the steps. Thank you!

@kanerogers

Awesome, @isaisachen, thanks for the update!

I believe I'm having the null intent data problem too:

Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=9001, result=0, data=null} to activity {com.traxi/com.traxi.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.auth.api.signin.GoogleSignInResult.isSuccess()' on a null object reference
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3706)
       at android.app.ActivityThread.handleSendResult(ActivityThread.java:3749)
       at android.app.ActivityThread.access$1400(ActivityThread.java:153)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1400)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5441)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.auth.api.signin.GoogleSignInResult.isSuccess()' on a null object reference
       at com.traxi.AuthenticationModule.onActivityResult(AuthenticationModule.java:111)
       at com.facebook.react.bridge.ReactContext.onActivityResult(ReactContext.java:261)
       at com.facebook.react.XReactInstanceManagerImpl.onActivityResult(XReactInstanceManagerImpl.java:627)
       at com.facebook.react.ReactActivityDelegate.onActivityResult(ReactActivityDelegate.java:135)
       at com.facebook.react.ReactActivity.onActivityResult(ReactActivity.java:77)
       at android.app.Activity.dispatchActivityResult(Activity.java:6508)
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3702)
       at android.app.ActivityThread.handleSendResult(ActivityThread.java:3749)
       at android.app.ActivityThread.access$1400(ActivityThread.java:153)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1400)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5441)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)

As others have pointed out in this thread, the issue appears to be related to Xiaomi devices. That particular stack trace is from a Redmi Note 3.

Please let me know if I can provide any more information; I have a capture of the crash from Crashlytics, and I'd be happy to give you any more information that might help you solve this issue.

Thanks again for your help and for being so responsive over GitHub - it's great to see. 😁

@isaisachen

@kanerogers Thanks for the info! Do you think that Xiaomi device is lacking of Google Play services? I do have an unproved theory for that case, will try to address in v10.4.

In the mean time, please check for whether GoogleSignInResult is null. Thank you.

@kanerogers

Thanks for the response @isaisachen!

I've been trying to get in touch with the user to find out, but no luck. Any programmatic way to check for the existence of Play Services? I could log that in my Crashlytics session.

re: checking for null, I've purposely left this crash in so I can be aware of it happening. The application is useless without authentication anyway, so there's no logical way for the user to progress if this error happens.

re: your theory, I believe you may be correct. Doing a quick Google around yields some results like the following

Xiaomi Redmi Note 3 and Redmi Note 3 Pro are the company first all-metal design phablets currently announced only in China. As the device is China exclusive, we don’t find Google Play Store app installed instead we find Mi Store and other Android apps. So, in this post we will guide to Install Google Play Store on your Xiaomi Redmi Note 3.

What may be happening is that users are only installing Play Store, but not Play Services. For a non-developer, it's not really apparent what the point of installing Play Service is, so they'd probably skip this step.

@isaisachen

@kanerogers Thanks for the research.

For Xiaomi devices, the mainland China version doesn't have Play Store or Google Play services; but for versions distributed in most of other countries, they do. However, sometimes some devices don't have most up-to-date Google Play services.

Yes, it will be helpful to log and see if (new-enough) Google Play services is available on those user's device.

We offer below method GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) to check whether there's a new enough (i.e. newer than the SDK version) Google Play services on the device. Unfortunately, we didn't offer any helper function in the SDK to print out the exact version of Google Play services. You can get it by yourself from PackageManager#getPackageInfo (package name is GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE) and there's a versionCode field in PackageInfo.

@kanerogers
@cargo8
cargo8 commented Jan 24, 2017 edited

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment