0

Problem

I was developing an android application in Java in which I have to integrate the Payment module for the user to pay to use the specific service. I was using the Stripe's payment API for that. I used Stripe's android-SDK for the implementation of payment sheet which is used to take a payout from the user.

When I press Pay button on the payment sheet after entering the card details, the app crashes in the Android 14 mobile in which I was testing. I tested it with the other android version where it works fine. I think this is the internal Android 14 beta error I am facing.

I am getting the following error when the App crash

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.bigstride.jobportal_company, PID: 9012
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bigstride.jobportal_company/com.stripe.android.payments.StripeBrowserLauncherActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CHOOSER (has extras) }
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3782)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:205)
        at android.os.Looper.loop(Looper.java:294)
        at android.app.ActivityThread.main(ActivityThread.java:8176)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
     Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CHOOSER (has extras) }
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2239)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1878)
        at android.app.Activity.startActivityForResult(Activity.java:5589)
        at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:728)
        at androidx.core.app.ActivityCompat$Api16Impl.startActivityForResult(ActivityCompat.java:809)
        at androidx.core.app.ActivityCompat.startActivityForResult(ActivityCompat.java:246)
        at androidx.activity.ComponentActivity$2.onLaunch(ComponentActivity.java:243)
        at androidx.activity.result.ActivityResultRegistry$2.launch(ActivityResultRegistry.java:175)
        at androidx.activity.result.ActivityResultLauncher.launch(ActivityResultLauncher.java:47)
        at com.stripe.android.payments.StripeBrowserLauncherActivity.onCreate(StripeBrowserLauncherActivity.kt:56)
        at android.app.Activity.performCreate(Activity.java:8595)
        at android.app.Activity.performCreate(Activity.java:8573)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3764)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loopOnce(Looper.java:205) 
        at android.os.Looper.loop(Looper.java:294) 
        at android.app.ActivityThread.main(ActivityThread.java:8176) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) 

What the payment sheet does is that when I press pay button it redirects to a browser link with the hooks.stripe.com link where it process the payment. but in the case of Android 14 the App gets crashed because I think it is not able to open the browser.

It would be great if there is any workaround for this issue.

any help can be great, thank you

I expected it to open the browser to process payment but it cashes instead and stops the payment process. I used the official Stripe documentation for the implementation here us the link for the docs

2 Answers2

0

You could use a custom webview inside the application so that Stripe isn't depending on a browser being installed on the device.

The next option is to check if there's a browser installed with "android.intent.action.CHOOSER" and if there isn't you can prompt the user to install a compatible browser.

The last one is more of a last case scenario but you can catch the "ActivityNotFoundException" and then you can display an error message to the user instead of it resulting in a crash. Good luck.

  • The Stripe Payment sheet which open's and then it redirects it to the browser. this is done with the Stripe-SDK itself, I didn't find any ways to externally open link in the webView. is there any workaround for that ? – Devarsh Ukani Jul 07 '23 at 11:35
0

A similar ticket was filed in stripe-android github repo. Can you try the workaround and see if it works?

qichuan
  • 1,110
  • 7
  • 8