flutter-braintree icon indicating copy to clipboard operation
flutter-braintree copied to clipboard

Android Crash - PayPal RuntimeException: Failure delivering result ResultInfo

Open alefl10 opened this issue 11 months ago • 6 comments

Attempting to use PayPal on Android crashes my Flutter App, and outputs the following console error

D/AndroidRuntime(12067): Shutting down VM
E/AndroidRuntime(12067): FATAL EXCEPTION: main
E/AndroidRuntime(12067): Process: com.ivisa.services.stg, PID: 12067
E/AndroidRuntime(12067): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1056, result=0, data=null} to activity {com.ivisa.services.stg/com.ivisa.services.MainActivity}: java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(12067): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:5323)
E/AndroidRuntime(12067): 	at android.app.ActivityThread.handleSendResult(ActivityThread.java:5362)
E/AndroidRuntime(12067): 	at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67)
E/AndroidRuntime(12067): 	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
E/AndroidRuntime(12067): 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime(12067): 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime(12067): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
E/AndroidRuntime(12067): 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(12067): 	at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(12067): 	at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(12067): 	at android.app.ActivityThread.main(ActivityThread.java:7872)
E/AndroidRuntime(12067): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(12067): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(12067): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
E/AndroidRuntime(12067): Caused by: java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(12067): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:431)
E/AndroidRuntime(12067): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:272)
E/AndroidRuntime(12067): 	at com.example.flutter_braintree.FlutterBraintreePlugin.onActivityResult(FlutterBraintreePlugin.java:134)
E/AndroidRuntime(12067): 	at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEngineConnectionRegistry.java:774)
E/AndroidRuntime(12067): 	at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onActivityResult(FlutterEngineConnectionRegistry.java:422)
E/AndroidRuntime(12067): 	at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:857)
E/AndroidRuntime(12067): 	at io.flutter.embedding.android.FlutterFragment.onActivityResult(FlutterFragment.java:1251)
E/AndroidRuntime(12067): 	at io.flutter.embedding.android.FlutterFragmentActivity.onActivityResult(FlutterFragmentActivity.java:653)
E/AndroidRuntime(12067): 	at android.app.Activity.dispatchActivityResult(Activity.java:8628)
E/AndroidRuntime(12067): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:5316)
E/AndroidRuntime(12067): 	... 13 more
I/Process (12067): Sending signal. PID: 12067 SIG: 9

As far as I know, this problem usually arises in a plugin when the result of an onActivityResult call is propagated more than once or if the plugin's result handling code is triggered multiple times.

This is NOT affecting iOS.

alefl10 avatar Mar 07 '24 12:03 alefl10

Hi @alefl10 Have you fixed this problem yet?

TuanMai777 avatar Apr 26 '24 03:04 TuanMai777

@TuanMai777 no, the error still persists.

@pikaju are there any updates on it?

alefl10 avatar Apr 29 '24 11:04 alefl10

Try to see if this solve your issue https://github.com/pikaju/flutter-braintree/issues/166

nicolobozzato avatar Jul 15 '24 10:07 nicolobozzato

Hey @nicolobozzato! Nope.. that didn't help. I still got the same issue which logged the same error details as included in the description and then crashed the app.

alefl10 avatar Jul 15 '24 11:07 alefl10

@nicolobozzato @pikaju @claudius-kienle @TuanMai777

The issue must be coming from the methodChannel requestPaypalNonce, as that's what's been executed after calling Braintree.requestPaypalNonce.

/// Requests a PayPal payment method nonce.
///
/// [authorization] must be either a valid client token or a valid tokenization key.
/// [request] should contain all the information necessary for the PayPal request.
///
/// Returns a [Future] that resolves to a [BraintreePaymentMethodNonce] if the user confirmed the request,
/// or `null` if the user canceled the Vault or Checkout flow.
static Future<BraintreePaymentMethodNonce?> requestPaypalNonce(
  String authorization,
  BraintreePayPalRequest request,
) async {
  final result = await _kChannel.invokeMethod('requestPaypalNonce', {
    'authorization': authorization,
    'request': request.toJson(),
  });
  if (result == null) return null;
  return BraintreePaymentMethodNonce.fromJson(result);
}

alefl10 avatar Aug 19 '24 23:08 alefl10

Any update on the issue?

Adithyan2295 avatar Sep 02 '24 06:09 Adithyan2295