square / in-app-payments-flutter-plugin

Flutter Plugin for Square In-App Payments SDK
https://developer.squareup.com/docs
Apache License 2.0
338 stars 121 forks source link

Android crash when hitting back button in release mode #165

Closed Hadii1 closed 3 years ago

Hadii1 commented 3 years ago

I'm implementing card payment with InAppPayments.startCardEntryFlow, all works well but when the card activity launches and I hit the back button in the app it exits to the device home screen and throws an Illegal argument exception exception. In debug mode, all works well and the app just goes back to the previous screen when pressing back. I'm setting the square app id correctly.

Here is the log:

E/AndroidRuntime(14460): FATAL EXCEPTION: EventsUploadThread
E/AndroidRuntime(14460): Process: levant.wholesale.ecommerce.dev, PID: 14460
E/AndroidRuntime(14460): java.lang.IllegalArgumentException: Method return type must not include a type variable or wildcard: k.b<?>
E/AndroidRuntime(14460):     for method h.a
E/AndroidRuntime(14460):    at k.w.o(Unknown Source:46)
E/AndroidRuntime(14460):    at k.w.n(Unknown Source:1)
E/AndroidRuntime(14460):    at k.t.b(Unknown Source:40)
E/AndroidRuntime(14460):    at k.s.d(Unknown Source:24)
E/AndroidRuntime(14460):    at k.s$a.invoke(Unknown Source:32)
E/AndroidRuntime(14460):    at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
E/AndroidRuntime(14460):    at $Proxy4.a(Unknown Source)
E/AndroidRuntime(14460):    at sqip.internal.j1.a$a.l(Unknown Source:68)
E/AndroidRuntime(14460):    at sqip.internal.j1.a$a.f(Unknown Source:0)
E/AndroidRuntime(14460):    at sqip.internal.j1.a$a$b.run(Unknown Source:4)
E/AndroidRuntime(14460):    at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187)
E/AndroidRuntime(14460):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
E/AndroidRuntime(14460):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(14460):    at java.lang.Thread.run(Thread.java:784)

I tried to create a minimal example to reproduce this but I couldn't. On the minimal example I created the app worked perfectly.

Expected behavior To go back to the previous screen when pressing back.

• No issues found!

Code used is just a simple button with

 onTap: () async {
                              await InAppPayments.startCardEntryFlow(
                                onCardNonceRequestSuccess: (d) {
                                  print('success');
                                },
                                onCardEntryCancel: () {
                                  print('cancelled');
                                },
                              );
Hadii1 commented 3 years ago

I created a new project and copied all the dart code to it and the problem was solved.