sumup / sumup-android-sdk

Sample App for the SumUp Android SDK
Other
100 stars 28 forks source link

Crash when network connectivity is turned off #182

Open Milszym opened 2 years ago

Milszym commented 2 years ago

The app is crashing when turning off network connectivity during the payment process due to:

NullPointerException in com.sumup.android.logging.Log.getFileName

Full Stacktrace is down below at the end of the issue description.

SumUp Version 3.4.0

Prerequisites

  1. Authorize SumUp SDK in your app
  2. Connect to the SumUp terminal
  3. Connect to Wifi or cellular data

Steps to reproduce

  1. Start SumUp payment by invoking SumUpAPI::checkout method
  2. Wait for the payment amount to show up on the terminal
  3. Once the payment is visible on the terminal, please turn off the Wifi and Cellular data on your Android device
  4. Wait and observe the result

Expected Result SumUp SDK handles the lack of network gracefully by showing some relevant message on the screen which will notify the user that there is no network connectivity at the moment and the payment can't be processed.

Actual Result SumUp SDK crashes after a few seconds.

Similar issue Similar issue, caused by the same line of code (com.sumup.android.logging.Log.getFileName (Log.java:38)), but invoked from a different class: https://github.com/sumup/sumup-android-sdk/issues/162

Stacktrace of this issue

Fatal Exception: org.greenrobot.eventbus.EventBusException: Invoking subscriber failed
       at org.greenrobot.eventbus.EventBus.handleSubscriberException(EventBus.java:527)
       at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:509)
       at org.greenrobot.eventbus.EventBus.postToSubscription(EventBus.java:434)
       at org.greenrobot.eventbus.EventBus.postSingleEventForEventType(EventBus.java:411)
       at org.greenrobot.eventbus.EventBus.postSingleEvent(EventBus.java:384)
       at org.greenrobot.eventbus.EventBus.post(EventBus.java:265)
       at com.sumup.merchant.reader.cardreader.ReaderCoreManager$1.onDeviceAttached(SourceFile:5)
       at com.sumup.reader.core.CardReaderManager.deviceAttached(CardReaderManager.java:7)
       at com.sumup.reader.core.Devices.PinPlusReaderDevice.onTransportError(SourceFile:7)
       at com.sumup.reader.core.Devices.PinPlusReaderDevice.onTransportError(PinPlusReaderDevice.java:1)
       at com.sumup.reader.core.pinplus.TransportController$InitializationErrorAction.run(SourceFile:2)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8538)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.contains(java.lang.CharSequence)' on a null object reference
       at com.sumup.android.logging.Log.getFileName(Log.java:38)
       at com.sumup.android.logging.Log.getLog(Log.java:230)
       at com.sumup.android.logging.Log.generateErrorLog(Log.java:225)
       at com.sumup.android.logging.Log.e(Log.java:201)
       at com.sumup.merchant.reader.controllers.CardReaderSetupController.onDetectionError(SourceFile:1)
       at com.sumup.merchant.reader.controllers.CardReaderSetupController.onCardReaderNotFound(SourceFile:1)
       at java.lang.reflect.Method.invoke(Method.java)
       at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:507)
       at org.greenrobot.eventbus.EventBus.postToSubscription(EventBus.java:434)
       at org.greenrobot.eventbus.EventBus.postSingleEventForEventType(EventBus.java:411)
       at org.greenrobot.eventbus.EventBus.postSingleEvent(EventBus.java:384)
       at org.greenrobot.eventbus.EventBus.post(EventBus.java:265)
       at com.sumup.merchant.reader.cardreader.ReaderCoreManager$1.onDeviceAttached(SourceFile:5)
       at com.sumup.reader.core.CardReaderManager.deviceAttached(CardReaderManager.java:7)
       at com.sumup.reader.core.Devices.PinPlusReaderDevice.onTransportError(SourceFile:7)
       at com.sumup.reader.core.Devices.PinPlusReaderDevice.onTransportError(PinPlusReaderDevice.java:1)
       at com.sumup.reader.core.pinplus.TransportController$InitializationErrorAction.run(SourceFile:2)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8538)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
terrypearson commented 1 year ago

This is a fairly major issue that could be addressed fairly easily. According to Google Crashlytics, we see this happening as well (basically the same stack trace) for users. The average individual user that is using SumUp on our platform has seen greater than 15 crashes as a result of this bug.

OliverHoffmann commented 1 year ago

I am still getting crash logs like the above, even when network is available but slow. Is it still not fixed yet or may it be another bug?