khalti / checkout-sdk-android

The official Khalti SDK for KPG2
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

I got an error after added OTP and clicked on payment button in khalti SDK #6

Closed BhavinVala18 closed 2 months ago

BhavinVala18 commented 3 months ago

Can you please check and help me to resolve this issue

java.lang.RuntimeException: Can't create handler inside thread Thread[DefaultDispatcher-worker-2,5,main] that has not called Looper.prepare()
                                                                                                        at android.os.Handler.<init>(Handler.java:227)
                                                                                                        at android.os.Handler.<init>(Handler.java:129)
                                                                                                        at android.app.Dialog.<init>(Dialog.java:143)
                                                                                                        at android.app.Dialog.<init>(Dialog.java:197)
                                                                                                        at androidx.activity.ComponentDialog.<init>(ComponentDialog.kt:42)
                                                                                                        at androidx.appcompat.app.AppCompatDialog.<init>(AppCompatDialog.java:55)
                                                                                                        at androidx.appcompat.app.AlertDialog.<init>(AlertDialog.java:98)
                                                                                                        at androidx.appcompat.app.AlertDialog$Builder.create(AlertDialog.java:983)
                                                                                                        at com.app.phase_two.PaymentMethodFragment.showFailureDialog(PaymentMethodFragment.java:2971)
                                                                                                        at com.app.phase_two.PaymentMethodFragment.-$$Nest$mshowFailureDialog(Unknown Source:0)
                                                                                                        at com.app.phase_two.PaymentMethodFragment$18$2.invoke(PaymentMethodFragment.java:1935)
                                                                                                        at com.khalti.checkout.service.verification.VerificationRepository$verify$1$2.invoke(VerificationRepository.kt:45)
                                                                                                        at com.khalti.checkout.service.verification.VerificationRepository$verify$1$2.invoke(VerificationRepository.kt:26)
                                                                                                        at com.khalti.checkout.resource.Result.match(Result.kt:17)
                                                                                                        at com.khalti.checkout.service.verification.VerificationRepository$verify$1.invokeSuspend(VerificationRepository.kt:26)
                                                                                                        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
                                                                                                        Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@f925f96, Dispatchers.Default]``
Ishwor-Shrestha commented 3 months ago

Hi @BhavinVala18, Could you also provide some sample code so that we can try reproducing the issue. I can see a showFailureDialog being invoked from PaymentMethodFragment.java in the stacktrace above. Could you verify if this dialog is being triggered from the main thread?

acpmasquerade commented 3 months ago

Please elaborate with some context atleast

BhavinVala18 commented 3 months ago

Hi @BhavinVala18, Could you also provide some sample code so that we can try reproducing the issue. I can see a showFailureDialog being invoked from PaymentMethodFragment.java in the stacktrace above. Could you verify if this dialog is being triggered from the main thread?

Yes showFailureDialog triggered from main thread.

Ishwor-Shrestha commented 3 months ago

@BhavinVala18 Please add minimum reproducible code for further investigation

BhavinVala18 commented 3 months ago

@Ishwor-Shrestha Okay I will try and let you know

Ishwor-Shrestha commented 2 months ago

I am closing this issue due inactivity. Please feel free to open a new issue if required.