flutter-stripe / flutter_stripe

Flutter SDK for Stripe.
https://pub.dev/packages/flutter_stripe
911 stars 502 forks source link

CustomerSheet crash when invoking initCustomerSheet() in Android #1589

Open alexhdez98 opened 5 months ago

alexhdez98 commented 5 months ago

Describe the bug Whenever invoking the Stripe.instance.initCustomerSheet() in Android, the application crashes with the error:

D/AndroidRuntime(14260): Shutting down VM
E/AndroidRuntime(14260): FATAL EXCEPTION: main
E/AndroidRuntime(14260): Process: com.xxx.xxx, PID: 14260
E/AndroidRuntime(14260): java.lang.NoSuchMethodError: No virtual method builder()Lcom/stripe/android/customersheet/CustomerSheet$Configuration$Builder; in class Lcom/stripe/android/customersheet/CustomerSheet$Configuration$Companion; or its super classes (declaration of 'com.stripe.android.customersheet.CustomerSheet$Configuration$Companion' appears in /data/app/~~-xxxx==/com.xxx.xxx-xxxx==/base.apk!classes20.dex)
E/AndroidRuntime( 14260):        at com.reactnativestripesdk.CustomerSheetFragment.onViewCreated(CustomerSheetFragment.kt:87)
E/AndroidRuntime( 14260):        at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3128)
E/AndroidRuntime( 14260):        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:552)
E/AndroidRuntime( 14260):        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
E/AndroidRuntime( 14260):        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1899)
E/AndroidRuntime( 14260):        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1817)
E/AndroidRuntime( 14260):        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1760)
E/AndroidRuntime( 14260):        at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:547)
E/AndroidRuntime( 14260):        at android.os.Handler.handleCallback(Handler.java:942)
E/AndroidRuntime( 14260):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 14260):        at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime( 14260):        at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime( 14260):        at android.app.ActivityThread.main(ActivityThread.java:7898)
E/AndroidRuntime( 14260):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 14260):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime( 14260):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

To Reproduce Steps to reproduce the behavior:

  1. Create a function to present the CustomerSheet:
await Stripe.instance.initCustomerSheet(
        customerSheetInitParams: CustomerSheetInitParams(
          customerId: customerExtId,
          customerEphemeralKeySecret: ephemeralKey['secret'],
        ),
      );

await Stripe.instance.presentCustomerSheet();
  1. Invoke this function.
  2. Observe a failure with the exception presented in the description.

Expected behavior Whenever this is invoked in iOS, it works just fine and presents the CustomerSheet with the payment methods associated with the customer.

Smartphone / tablet

jonasbark commented 5 months ago

Does this happen during debugging or only for released apps?

alexhdez98 commented 5 months ago

@jonasbark During debugging on Android. On iOS is working fine in release.

JakeFromChairy commented 2 months ago

Hello, is there any update on this item? I am also experiencing this issue on Android devices only.

remonh87 commented 2 months ago

Can you try it on the latest version. I was able to use the customer sheet in the example app

alexhdez98 commented 2 months ago

@remonh87 Seems the issue of not being able to even open the customer sheet has disappeared 👍 However, when adding a new payment method in the sheet, it crashes with the error:

E/AndroidRuntime(15315): FATAL EXCEPTION: main
E/AndroidRuntime(15315): Process: xxx.xxx.xxx, PID: 15315
E/AndroidRuntime(15315): java.lang.IllegalArgumentException: Required value was null.
E/AndroidRuntime(15315):        at com.stripe.android.paymentsheet.forms.FormViewModel.<init>(FormViewModel.kt:69)
E/AndroidRuntime(15315):        at com.stripe.android.customersheet.injection.DaggerCustomerSheetViewModelComponent$FormViewModelSubcomponentImpl.getViewModel(DaggerCustomerSheetViewModelComponent.java:159)
E/AndroidRuntime(15315):        at com.stripe.android.customersheet.CustomerSheetViewModel.buildFormObserver(CustomerSheetViewModel.kt:1189)
E/AndroidRuntime(15315):        at com.stripe.android.customersheet.CustomerSheetViewModel.transitionToAddPaymentMethod(CustomerSheetViewModel.kt:770)
E/AndroidRuntime(15315):        at com.stripe.android.customersheet.CustomerSheetViewModel.transitionToAddPaymentMethod$default(CustomerSheetViewModel.kt:756)
E/AndroidRuntime(15315):        at com.stripe.android.customersheet.CustomerSheetViewModel.onAddCardPressed(CustomerSheetViewModel.kt:374)
E/AndroidRuntime(15315):        at com.stripe.android.customersheet.CustomerSheetViewModel.handleViewAction(CustomerSheetViewModel.kt:179)
E/AndroidRuntime(15315):        at com.stripe.android.customersheet.CustomerSheetActivity$onCreate$1$1$4$1.invoke(CustomerSheetActivity.kt:99)
E/AndroidRuntime(15315):        at com.stripe.android.customersheet.CustomerSheetActivity$onCreate$1$1$4$1.invoke(CustomerSheetActivity.kt:99)
E/AndroidRuntime(15315):        at com.stripe.android.customersheet.ui.CustomerSheetScreenKt$SelectPaymentMethod$1$1$1.invoke(CustomerSheetScreen.kt:135)
E/AndroidRuntime(15315):        at com.stripe.android.customersheet.ui.CustomerSheetScreenKt$SelectPaymentMethod$1$1$1.invoke(CustomerSheetScreen.kt:135)
E/AndroidRuntime(15315):        at androidx.compose.foundation.ClickablePointerInputNode$pointerInput$3.invoke-k-4lQ0M(Clickable.kt:895)
E/AndroidRuntime(15315):        at androidx.compose.foundation.ClickablePointerInputNode$pointerInput$3.invoke(Clickable.kt:889)
E/AndroidRuntime(15315):        at androidx.compose.foundation.gestures.TapGestureDetectorKt$detectTapAndPress$2$1.invokeSuspend(TapGestureDetector.kt:255)
E/AndroidRuntime(15315):        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(15315):        at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:179)
E/AndroidRuntime(15315):        at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:168)
E/AndroidRuntime(15315):        at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:474)
E/AndroidRuntime(15315):        at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:508)
E/AndroidRuntime(15315):        at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:497)
E/AndroidRuntime(15315):        at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:368)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl$PointerEventHandlerCoroutine.offerPointerEvent(SuspendingPointerInputFilter.kt:665)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl.dispatchPointerEvent(SuspendingPointerInputFilter.kt:544)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl.onPointerEvent-H0pRuoY(SuspendingPointerInputFilter.kt:566)
E/AndroidRuntime(15315):        at androidx.compose.foundation.AbstractClickablePointerInputNode.onPointerEvent-H0pRuoY(Clickable.kt:855)
E/AndroidRuntime(15315):        at androidx.compose.foundation.AbstractClickableNode.onPointerEvent-H0pRuoY(Clickable.kt:703)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:317)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.NodeParent.dispatchMainEventPass(HitPathTracker.kt:183)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.HitPathTracker.dispatchChanges(HitPathTracker.kt:102)
E/AndroidRuntime(15315):        at androidx.compose.ui.input.pointer.PointerInputEventProcessor.process-BIzXfog(PointerInputEventProcessor.kt:96)
E/AndroidRuntime(15315):        at androidx.compose.ui.platform.AndroidComposeView.sendMotionEvent-8iAsVTc(AndroidComposeView.android.kt:1446)
E/AndroidRuntime(15315):        at androidx.compose.ui.platform.AndroidComposeView.handleMotionEvent-8iAsVTc(AndroidComposeView.android.kt:1398)
E/AndroidRuntime(15315):        at androidx.compose.ui.platform.AndroidComposeView.dispatchTouchEvent(AndroidComposeView.android.kt:1338)
E/AndroidRuntime(15315):        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3169)
E/AndroidRuntime(15315):        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2845)
E/AndroidRuntime(15315):        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3169)
E/AndroidRuntime(15315):        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2845)
E/AndroidRuntime(15315):        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3169)
E/AndroidRuntime(15315):        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2845)
E/AndroidRuntime(15315):        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3169)
E/AndroidRuntime(15315):        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2845)
E/AndroidRuntime(15315):        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3169)
E/AndroidRuntime(15315):        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2845)
E/AndroidRuntime(15315):        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3169)
E/AndroidRuntime(15315):        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2845)
E/AndroidRuntime(15315):        at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:573)
E/AndroidRuntime(15315):        at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1911)
E/AndroidRuntime(15315):        at android.app.Activity.dispatchTouchEvent(Activity.java:4256)
E/AndroidRuntime(15315):        at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:70)
E/AndroidRuntime(15315):        at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:521)
E/AndroidRuntime(15315):        at android.view.View.dispatchPointerEvent(View.java:14899)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:6755)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:6526)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5995)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6057)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6018)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:6192)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6026)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:6249)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5999)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6057)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6018)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6026)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5999)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:9034)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8985)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:8941)
E/AndroidRuntime(15315):        at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:9177)
E/AndroidRuntime(15315):        at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:266)
E/AndroidRuntime(15315):        at android.os.MessageQueue.nativePollOnce(Native Method)
E/AndroidRuntime(15315):        at android.os.MessageQueue.next(MessageQueue.java:339)
E/AndroidRuntime(15315):        at android.os.Looper.loopOnce(Looper.java:179)
E/AndroidRuntime(15315):        at android.os.Looper.loop(Looper.java:344)
E/AndroidRuntime(15315):        at android.app.ActivityThread.main(ActivityThread.java:8212)
E/AndroidRuntime(15315):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(15315):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
E/AndroidRuntime(15315):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034)
E/AndroidRuntime(15315):        Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@3bcca2c, androidx.compose.runtime.BroadcastFrameClock@703acf5, StandaloneCoroutine{Cancelling}@5c17a8a, AndroidUiDispatcher@77368fb]
I/Process (15315): Sending signal. PID: 15315 SIG: 9

This is happening during debugging in Android only:

Smartphone / tablet

Thanks for your support!

remonh87 commented 2 months ago

Can you give me some code that I can use to reproduce the issue? I probably need to file a bug report to Stripe for it