question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google Pay crash when using 4.10.0 in some cases

See original GitHub issue

General information

  • SDK/Library version: 4.10.0
  • Environment: Production
  • Android Version and Device: Many devices, such as Galaxy A12 with Android 11

Issue description

When we are going to launch Google pay in version 4.10.0. It will crash sometimes.

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.activity.result.ActivityResultLauncher.launch(java.lang.Object)' on a null object reference
       at com.braintreepayments.api.GooglePayLifecycleObserver.launch(GooglePayLifecycleObserver.java:44)
       at com.braintreepayments.api.GooglePayClient$4$1.onResult(GooglePayClient.java:296)
       at com.braintreepayments.api.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:41)
       at com.braintreepayments.api.BraintreeClient$1.onAuthorizationResult(BraintreeClient.java:161)
       at com.braintreepayments.api.AuthorizationLoader.loadAuthorization(AuthorizationLoader.java:20)
       at com.braintreepayments.api.BraintreeClient.getAuthorization(BraintreeClient.java:170)
       at com.braintreepayments.api.BraintreeClient.getConfiguration(BraintreeClient.java:157)
       at com.braintreepayments.api.GooglePayClient$4.onAuthorizationResult(GooglePayClient.java:275)
       at com.braintreepayments.api.AuthorizationLoader.loadAuthorization(AuthorizationLoader.java:20)
       at com.braintreepayments.api.BraintreeClient.getAuthorization(BraintreeClient.java:170)
       at com.braintreepayments.api.GooglePayClient.requestPayment(GooglePayClient.java:271)
       at com.braintreepayments.api.GooglePayClient.requestPayment(GooglePayClient.java:228)
      .....

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
sshropshirecommented, Aug 17, 2022

@contissi it may be specific to Google Pay here. The workaround could be removed if tokenize were called in response to a user action e.g. a “Google Pay” button press, only because the host activity will presumably be in a RESUMED state.

We use Jetpack Lifecycle internally to register for an activity result in onCreate. The Handler workaround is a bit of a hack to get the code to execute on the next run loop, which will be executed after all of the pending lifecycle methods i.e. onCreate, onResume etc. have completed synchronously.

For now it is a good workaround. In the future, we should offer explicit support for onCreate tokenization by capturing a pending GooglePayRequest internally which will allow the SDK to defer launching the Google Pay flow until after Activity result registration is complete.

0reactions
Hector1990commented, Oct 18, 2022

I resolved this by:

  1. init google pay client in onCreate
  2. request payment in ‘onStart’
Read more comments on GitHub >

github_iconTop Results From Across the Web

react native - PaymentSheet Crashing on Android in v.0.19.0
On iOS everything works perfectly. To Reproduce I'm just following this Stripe Developers video about Accept a payment: export default function ...
Read more >
Troubleshoot Chrome crashes - Google Support
Crashing issues with Chrome or a ChromeOS device can be caused a number of things. Here are some potential issues you might encounter:...
Read more >
Brave should restore session gracefully after a crash #5512
In some cases, it doesn't properly save the session file (leaving them with an empty session). Expected behavior: When Brave is running: Session ......
Read more >
Release Notes | Firebase - Google
This page provides a changelog that lists new SDK releases and describes updates to the Firebase console and Firebase services.
Read more >
Bug listing with status RESOLVED with resolution UPSTREAM ...
... Bug:34744 - "OpenOffice freezes when rendering certain fonts with XFS" ... causes kernel oops" status:RESOLVED resolution:UPSTREAM severity:critical ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found