PurpleSoftSrl / sumup_flutter_plugin

A Flutter wrapper to use the SumUp SDK. With this plugin, your app can easily connect to a SumUp terminal, login and accept card payments on Android and iOS.
https://www.purplesoft.io
MIT License
17 stars 17 forks source link

App is crashing in Android 7 #20

Closed ot-repo closed 2 years ago

ot-repo commented 2 years ago

Hello,

I am trying to make a payment with Android 7 and the app is always crashing with the following exception. SumUp app is working without any problem.

Unfortunately I haven't found anything in google about that, maybe you can give me some clue.

Thank you in advance!

Kind Regards

E/AndroidRuntime(14624): FATAL EXCEPTION: main
E/AndroidRuntime(14624): Process: com.orders.tracker.v2, PID: 14624
E/AndroidRuntime(14624): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.orders.tracker.v2/com.sumup.merchant.reader.ui.activities.CardReaderPaymentAPIDrivenPageActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object com.sumup.merchant.reader.ReaderModuleCoreState.get(java.lang.Class)' on a null object reference
E/AndroidRuntime(14624):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
E/AndroidRuntime(14624):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
E/AndroidRuntime(14624):        at android.app.ActivityThread.-wrap12(ActivityThread.java)
E/AndroidRuntime(14624):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
E/AndroidRuntime(14624):        at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(14624):        at android.os.Looper.loop(Looper.java:154)
E/AndroidRuntime(14624):        at android.app.ActivityThread.main(ActivityThread.java:6119)
E/AndroidRuntime(14624):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(14624):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
E/AndroidRuntime(14624):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
E/AndroidRuntime(14624): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object com.sumup.merchant.reader.ReaderModuleCoreState.get(java.lang.Class)' on a null object reference
E/AndroidRuntime(14624):        at com.sumup.merchant.reader.ui.activities.SumUpReaderModuleBaseActivity.onCreate(SourceFile:1)
E/AndroidRuntime(14624):        at android.app.Activity.performCreate(Activity.java:6743)
E/AndroidRuntime(14624):        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
E/AndroidRuntime(14624):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
E/AndroidRuntime(14624):        ... 9 more
sstasi95 commented 2 years ago

Hi,

it happens to me when I initialise the sdk with a wrong affiliateKey and then I reinitialise it with the correct key. Login completes successfully but the app crashes on checkout. Try to uninstall the app and reinstall it.

Let me know if it works,

Simone

ot-repo commented 2 years ago

Hello Simone,

thanks for the quick answer. Unfortunately it did not help. I even restarted the android device and reset the Sumup device.

I believe it has to do with the android version(7.1). With Android latest versions my app is working without any problem.

Best Regards! Sinan

sstasi95 commented 2 years ago

I was finally able to test it on a Samsung SM-A510F with Android 7.0 and checkout works fine, so I don't know what could be the issue, but I don't think it's related to the Android version.

Could you tell me the exact phone model you are using, so I can test on the same device (as soon as I can find it)?

Or maybe you could try to debug the plugin example app and see what's wrong. Just clone/fork the project, put a real affiliate key in 'example/lib/main.dart' file at line 9, open 'example/android' folder in Android Studio and launch the app.

When you find the error, paste here the error output of logcat.

Simone

ot-repo commented 2 years ago

Hi,

I have tested it on a tablet with Android 7.1 it's working, as well.

The device, where it's not working is not a tablet but a pos system from Sunmi. It has actually a bit customised Android with version 7.0. https://www.youtube.com/watch?v=gdTbdQaeZ4c

As you said, I'll test the example app and see, if it's working or not.

Thanks again!

ot-repo commented 2 years ago

Hi,

I have installed the example on the Sunmi device and on a regular android Samsung Tablet. On both devices, after I inited Sumup, I pressed on the login button. The login window of Sumup has been opened. I entered my test account credentials but I got this login error:

"These login details are not valid. Please check your username and password and try again".

I tried it many times and even with different accounts. None of them worked. The possibility that I entered the wrong credentials is zero.

Login works fine on the browser and in my app.

Really don't know what's wrong now.

Thanks!

sstasi95 commented 2 years ago

Did you put your affiliate key in 'example/lib/main.dart' file at line 9? If you did, try to reinstall the app.

ot-repo commented 2 years ago

Yes I entered my affiliate key in main.dart file. I just reinstalled the app and I got the same login error. What's strange is that it's not even working with a regular tablet with android 8.1.0.

sstasi95 commented 2 years ago

I don't know what can be wrong, this error always happens to me when I forget to put the affiliate key, but reinstalling the app fixes it.

sstasi95 commented 2 years ago

I forgot one thing: you have to register the example app bundle id (io.purplesoft.sumup_example) on your SumUp dashboard. I'm sorry.

ot-repo commented 2 years ago

Oh I missed that, too. After I added the app bundle id, everything worked with the example app as expected. No exception or crash.

After that i tried it with my app and after I logged into Sumup, the app has crashed with the following exception:

E/AndroidRuntime(30987): FATAL EXCEPTION: main E/AndroidRuntime(30987): Process: com.orders.tracker.v2, PID: 30987 E/AndroidRuntime(30987): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.orders.tracker.v2/com.sumup.merchant.reader.ui.activities.CardReaderPaymentAPIDrivenPageActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object com.sumup.merchant.reader.ReaderModuleCoreState.get(java.lang.Class)' on a null object reference E/AndroidRuntime(30987): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665) E/AndroidRuntime(30987): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) E/AndroidRuntime(30987): at android.app.ActivityThread.-wrap12(ActivityThread.java) E/AndroidRuntime(30987): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) E/AndroidRuntime(30987): at android.os.Handler.dispatchMessage(Handler.java:102) E/AndroidRuntime(30987): at android.os.Looper.loop(Looper.java:154) E/AndroidRuntime(30987): at android.app.ActivityThread.main(ActivityThread.java:6119) E/AndroidRuntime(30987): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(30987): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) E/AndroidRuntime(30987): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) E/AndroidRuntime(30987): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object com.sumup.merchant.reader.ReaderModuleCoreState.get(java.lang.Class)' on a null object reference E/AndroidRuntime(30987): at com.sumup.merchant.reader.ui.activities.SumUpReaderModuleBaseActivity.onCreate(SourceFile:1) E/AndroidRuntime(30987): at android.app.Activity.performCreate(Activity.java:6743) E/AndroidRuntime(30987): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) E/AndroidRuntime(30987): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618) E/AndroidRuntime(30987): ... 9 more

I am totally confused now. If it has nothing to do with the library, then something in the app is causing that crash, but I have really no idea what it could be. I just use your library with some function calls. Nothing could be done wrong there. The app is working fine with other devices :(

Thank you very much for the support!

ot-repo commented 2 years ago

Hi,

after 2 days of trial and error, I have found out that the issue was caused by a flutter plugin called flutter_local_notifications. This plugin is problematic on Android 7 and somehow causing the Sumup to crash. After I disabled it, everything worked as expected.

Thank you very much for the great support!

Best Regards

rivella50 commented 1 year ago

Interesting, i've just seen a very similar error in Crashlytics on one of our customers Galaxy S21 5G (Android 12):

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.package/com.sumup.merchant.reader.identitylib.ui.activities.LoginActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.sumup.merchant.reader.ReaderModuleCoreState.inject(java.lang.Object)' on a null object reference
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4022)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'void com.sumup.merchant.reader.ReaderModuleCoreState.inject(java.lang.Object)' on a null object reference
       at com.sumup.merchant.reader.identitylib.ui.activities.LoginActivity.onCreate(SourceFile:8)

I cannot reproduce this crash on any of my Android devices around here. So far i had version 0.5.0 running, but i have just updated to version 0.6.0 - let's see if this helps. Also i've plugin flutter_local_notifications active in my project, but i cannot deactivate it as @ot-repo did. @ot-repo Do you know what caused the problems between those 2 plugins and is there an option that they can co-exist in the same Flutter project?