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

initGooglePay have the same init error that INIT_PAYMENTSHEET had #844

Closed
carl0shd opened this issue Mar 15, 2022 · 4 comments · Fixed by #846
Closed

initGooglePay have the same init error that INIT_PAYMENTSHEET had #844

carl0shd opened this issue Mar 15, 2022 · 4 comments · Fixed by #846

Comments

@carl0shd
Copy link

carl0shd commented Mar 15, 2022

Describe the bug
Hi Guys, I have multiple errors (+80 daily) in my production app using Stripe, when I call initGooglePay at the launch in my app, I have this error:

java.lang.NullPointerException: null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity

I think is the same error that the INIT_PAYMENTSHEET have in old versions: #783

This is the full log:

image

apparently, the error doesn't always occur, it seems to be random.

To Reproduce
Steps to reproduce the behavior:
N/A, I don't have instructions to reproduce this :(

Expected behavior
A clear and concise description of what you expected to happen.
Not have this crash.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context

Stripe RN version: 0.2.4
RN Version: 0.66

@carl0shd carl0shd changed the title initGooglePay have the same init error that INIT_PAYMENTSHEET have initGooglePay have the same init error that INIT_PAYMENTSHEET had Mar 15, 2022
@charliecruzan-stripe
Copy link
Collaborator

Please include your version of @stripe/stripe-react-native

@carl0shd
Copy link
Author

Hi @charliecruzan-stripe, actually the app uses version 0.2.4

@charliecruzan-stripe
Copy link
Collaborator

thanks :) fix incoming, it's extremely helpful that you included the crash logs in your issue report 👏

@goguda
Copy link

goguda commented Apr 8, 2022

Screenshot_20220408_143750

Same issue seems to occur at line 244 in StripeSdkModule.kt as well... null check needed here too?

I find it strange because based on visit logs I believe this is occurring without the user even interacting with any Stripe APIs yet, other than StripeProvider wrapping the root of the app.

Looking at line 244 of StripeSdkModule.kt...

(currentActivity as AppCompatActivity).supportFragmentManager.beginTransaction().add(paymentLauncherFragment, "payment_launcher_fragment").commit()

Taking a quick look at the internals of the library, my concern is, is a null check enough, or are null checks really just masking another problem? Should currentActivity ever actually be null in this case if the RN app has to be open for any of these API calls to even occur (as far as I know)?

Since currentActivity is null in the initialize method, if a null check was introduced and initialize was called while currentActivity was indeed null, would the Stripe SDK then be uninitialized in the RN app?

It also doesn't seem to be happening to every user, but I am having a few Android users per day trigger this error on my side in production. I cannot seem to reproduce it myself, sadly. It seems to happen across a wide range of Android devices. All my errors have interestingly happened on Android 10, 11 or 12:

image
image
image
image
image
image
image
image
image

Wish I could get some more info on exactly what is causing it, but this is all I've got.

I'm using stripe-react-native v. 0.6.0, but it was happening in older versions as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants