Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE on CustomTabsManagerActivity.onResume #1090

Closed
yinzcam-android opened this issue Dec 29, 2020 · 13 comments
Closed

NPE on CustomTabsManagerActivity.onResume #1090

yinzcam-android opened this issue Dec 29, 2020 · 13 comments
Assignees
Labels
auth Related to the Auth category/plugins bug Something isn't working

Comments

@yinzcam-android
Copy link

yinzcam-android commented Dec 29, 2020

Describe the bug

We are trying to setup AWS web sign-in for the Cavaliers official Android app. signInWithWebUI works fine. When we try to logout, we get the logout success callback but then it crashes.

To Reproduce
When we try to signOut after signInWithWebUI

Amplify.Auth.signOut(
    () -> Log.d(TAG, "Auth: log out successfully"),
    error -> Log.e(TAG, "Auth: log out" + error.toString())
);

Environment Information (please complete the following information):

  • Amplify Android version: 2.19.3
  • Devices: Sansung Galaxy Note 10, Pixel 2
  • Android Version: Android 10
  • Specific to simulators: No

Additional context
Stack trace:

2020-12-29 15:18:32.018 26833-26833/com.detroitlabs.cavaliers E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.detroitlabs.cavaliers, PID: 26833
    java.lang.RuntimeException: Unable to resume activity {com.detroitlabs.cavaliers/com.amazonaws.mobileconnectors.cognitoauth.activities.CustomTabsManagerActivity}: 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:4657)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4690)
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2267)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
     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:1713)
        at android.app.Activity.startActivityForResult(Activity.java:5258)
        at android.app.Activity.startActivityForResult(Activity.java:5203)
        at android.app.Activity.startActivity(Activity.java:5587)
        at android.app.Activity.startActivity(Activity.java:5555)
        at com.amazonaws.mobileconnectors.cognitoauth.activities.CustomTabsManagerActivity.onResume(CustomTabsManagerActivity.java:68)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1454)
        at android.app.Activity.performResume(Activity.java:8111)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4647)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4690) 
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) 
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2267) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:237) 
        at android.app.ActivityThread.main(ActivityThread.java:8167) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100) ```
@changxu0306
Copy link
Contributor

Thank you for reporting this issue. From your code snippet, it seems that you are using our Amplify framework. I'll move your issue to our Amplify github repository.

@changxu0306 changxu0306 transferred this issue from aws-amplify/aws-sdk-android Jan 6, 2021
@changxu0306 changxu0306 added the auth Related to the Auth category/plugins label Jan 6, 2021
@yinzcam-android
Copy link
Author

Any update regarding the issue?

@richardmcclellan richardmcclellan added the bug Something isn't working label Jan 20, 2021
@rjuliano
Copy link
Contributor

rjuliano commented Feb 3, 2021

@yinzcam-android Would you be able to test this with the latest version of Amplify? The latest version of Amplify is 1.16.11 which uses version 2.22.1 of the low level SDK.

I haven't been able to reproduce the crash on logout using this sample code, but did run into a different issue unrelated to this.

Also, are you using an external Idp or logging in with users created in the user pool? I tested mine using google as an Idp. Going to try with user pool users now.

@yinzcam-android
Copy link
Author

yinzcam-android commented Feb 3, 2021 via email

@yinzcam-android
Copy link
Author

yinzcam-android commented Feb 3, 2021 via email

@yinzcam-android
Copy link
Author

yinzcam-android commented Feb 3, 2021 via email

@rjuliano
Copy link
Contributor

rjuliano commented Feb 6, 2021

I've tried a few different things to no avail. I ran the test APK on a Pixel 2 with Android 10 in DeviceFarm and was able to login and logout multiple times without experiencing a crash.

I did a bit of research based on the stack trace you posted. Found a post on stack overflow that may or may not be relevant in this case.

Does the device you're testing the on have Google Play Services enabled?

@yinzcam-android
Copy link
Author

yinzcam-android commented Feb 8, 2021 via email

@rjuliano
Copy link
Contributor

I created a sample app that you can run against your backend. This will (hopefully) help narrow down the differences between your environment and mine. The app is pretty simple. It has an activity with a login and logout button and mimics the code you provided.

App repo: https://github.com/rjuliano/amplify-samples-android
branch: amplify/auth-sample
App dir: amplify-auth-app

All you need to do is drop your amplifyconfiguration.json file under amplify-auth-app/amplifyauthsample/src/main/res/raw. Then change the app_scheme string in amplify-auth-app/amplifyauthsample/src/main/res/values/strings.xml

Your app is obviously far more complex that this sample app, but as I said, maybe this will help us narrow down the source of the problem.

@yinzcam-android
Copy link
Author

yinzcam-android commented Feb 12, 2021 via email

@yinzcam-android
Copy link
Author

yinzcam-android commented Feb 12, 2021 via email

@raphkim
Copy link
Contributor

raphkim commented Jun 7, 2021

This issue is now resolved with v1.17.8. Please follow the updated documentation to apply this fix :)

@raphkim raphkim closed this as completed Jun 7, 2021
@Mohammad-amleh
Copy link

i countered this problem on v2.14.6 @raphkim @richardmcclellan any help ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Related to the Auth category/plugins bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants