AppAuth-Android: NPE on AuthorizationManagementActivity.onResume (from Android framework?)

I can’t reproduce it myself, but on an app with around half million active users it’s happening on production from time to time. (we are using the latest AppAuth version 0.7.0).

Usually happening on these devices:

  • Huawei 荣耀5X (HNKIW-Q) [Android 6.0]
  • Galaxy TabS 10.5 (chagalllte) [Android 6.0]
  • Gigaset GS170 (GS170) [Android 7.0]
  • Galaxy J1 (j13g) [Android 4.4]
  • Samsung Galaxy S5 mini (kminilte) [Android 6.0]

NPE:

java.lang.NullPointerException: android.app.Instrumentation in Attempt to invoke virtual method ‘boolean android.content.Intent.migrateExtraStreamToClipData()’ on a null object reference.execStartActivity

Stack trace:

at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4225)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3426)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7331)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData()' on a null object reference
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1534)
at android.app.Activity.startActivityForResult(Activity.java:4298)
at android.app.Activity.startActivityForResult(Activity.java:4245)
at android.app.Activity.startActivity(Activity.java:4582)
at android.app.Activity.startActivity(Activity.java:4550)
at net.openid.appauth.AuthorizationManagementActivity.onResume(AuthorizationManagementActivity.java)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1287)
at android.app.Activity.performResume(Activity.java:7015)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4214)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3426)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7331)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 1
  • Comments: 15 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Hi, I believe I found the cause for this crash:

It occurs when you open the authorization request twice in a row (e.g. double-clicking your app’s login button which calls the AppAuth SDK twice via “performAuthorizationRequest” or “getAuthorizationRequestIntent”). The crash occurs after completing the login process and it tries to return back to your app.

I am temporarily fixing this issue by adding a boolean in my app to determine if the authorization is occurring already.

Our tester has managed to reproduce this problem. This happens if the user interrupts the flow, by following steps:

  • Initiates the sign-in
  • In web view, clicks the 3 dots menu, open in chrome
  • Goes back to the app, so the auth flow is interrupted
  • At some point later goes to chrome, finishes the sign-in process and then when the app get’s a callback, the app crashes.

Stacktrace from our reproduction:

Android: 8.1.0
Android Build: OPP6.171019.012
Manufacturer: LGE
Model: Nexus 5X
Thread: main-2
CrashReporter Key: 178ec6e2-b9b0-428d-908f-bbc7e8bc8f7b
Start Date: 2018-03-09T15:12:31.570Z
Date: 2018-03-09T15:21:13.380Z

java.lang.RuntimeException: Unable to resume activity {com.marktguru.android.beta/net.openid.appauth.AuthorizationManagementActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData()' on a null object reference
	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3581)
	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3621)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2862)
	at android.app.ActivityThread.-wrap11(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:164)
	at android.app.ActivityThread.main(ActivityThread.java:6494)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData()' on a null object reference
	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1609)
	at android.app.Activity.startActivityForResult(Activity.java:4487)
	at android.app.Activity.startActivityForResult(Activity.java:4445)
	at android.app.Activity.startActivity(Activity.java:4806)
	at android.app.Activity.startActivity(Activity.java:4774)
	at net.openid.appauth.AuthorizationManagementActivity.onResume(AuthorizationManagementActivity.java:218)
	at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1355)
	at android.app.Activity.performResume(Activity.java:7107)
	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3556)
	... 10 more