sumup / sumup-android-sdk

Sample App for the SumUp Android SDK
Other
101 stars 29 forks source link

App crashes occasionally with NullPointerException in LoadSumUpPaymentsActivity #109

Open christxph opened 4 years ago

christxph commented 4 years ago

We are occasionally getting this crash report in Crashlytics and have also had it happen in debug builds. This happens because UserModel#mUserDetails is null when calling UserModel#getBusiness.

The attached crash log is from SumUp SDK v3.2.2 on Android 7.1 but it happens on various device+OS combinations.

image image

2020-02-20 14:47:00.133 7294-7294/com.example.app E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.app, PID: 7294
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.sumup.merchant.api.LoadSumUpPaymentsActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'com.sumup.merchant.Models.UserDetails$Business com.sumup.merchant.Models.UserDetails.getBusiness()' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6121)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.sumup.merchant.Models.UserDetails$Business com.sumup.merchant.Models.UserDetails.getBusiness()' on a null object reference
        at com.sumup.merchant.Models.UserModel.getBusiness(SourceFile:316)
        at com.sumup.merchant.Models.UserModel.getServerCurrencyCode(SourceFile:341)
        at com.sumup.merchant.Models.OrderModel.getCurrency(SourceFile:272)
        at com.sumup.merchant.api.LoadSumUpPaymentsActivity.getErrorMessageForApiInformation(SourceFile:660)
        at com.sumup.merchant.api.LoadSumUpPaymentsActivity.validateApiInformation(SourceFile:371)
        at com.sumup.merchant.api.LoadSumUpPaymentsActivity.onStart(SourceFile:158)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1249)
        at android.app.Activity.performStart(Activity.java:6740)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2629)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727) 
        at android.app.ActivityThread.-wrap12(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6121) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) 
pimvdmolen commented 4 years ago

@christxph did you manage to fix this? I've got the exact same error and don't know how to solve this.

christxph commented 4 years ago

@pimvdmolen Unfortunately not, as this crash is happening in a SumUp Activity LoadSumUpPaymentsActivity, which is outside of the host app's control. So this would need to be fixed in the SDK.

pimvdmolen commented 4 years ago

@christxph thank you for your reply. I had contact with sumup and they changed the scope which i used to connect with. After they did that the error was gone so maybe this might be also the solution for you.

christxph commented 3 years ago

Is there any update on this? This crash is still the most common one for our app.

christxph commented 3 years ago

This is still happening in v3.3.0 of the SDK, just with a slightly different stacktrace because some classes were moved in the recent SDK update:

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'com.sumup.merchant.reader.identitylib.models.IdentityModel$Country com.sumup.merchant.reader.identitylib.models.IdentityModel$Business.getCountry()' on a null object reference
       at com.sumup.merchant.reader.identitylib.models.IdentityModel.getServerCurrencyCode(IdentityModel.java:188)
       at com.sumup.merchant.reader.models.OrderModel.getCurrency(OrderModel.java:248)
       at com.sumup.merchant.reader.models.AffiliateModel.getErrorMessageForApiInformation(AffiliateModel.java:244)
       at com.sumup.merchant.reader.ui.activities.CardReaderPaymentAPIDrivenPageActivity.validateApiInformation(CardReaderPaymentAPIDrivenPageActivity.java:235)
       at com.sumup.merchant.reader.ui.activities.CardReaderPaymentAPIDrivenPageActivity.onSafeCreate(CardReaderPaymentAPIDrivenPageActivity.java:150)
       at com.sumup.merchant.reader.ui.activities.SumUpReaderModuleBaseActivity.onCreate(SumUpReaderModuleBaseActivity.java:50)
       at android.app.Activity.performCreate(Activity.java:7957)
       at android.app.Activity.performCreate(Activity.java:7946)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3598)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3775)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2261)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:237)
       at android.app.ActivityThread.main(ActivityThread.java:8107)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

Is this issue being worked on or is there any workaround to prevent this crash? This is happening on a high percentage of our app users.

Bas94 commented 3 years ago

We are also affected by this issue. We only see this crash happening with some customers but it is happening. Any investigations here?

lechld commented 2 years ago

Having exact same issue. But I guess this repo is dead anyhow.

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{mypackage.something/com.sumup.merchant.reader.ui.activities.CardReaderPaymentAPIDrivenPageActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'com.sumup.merchant.reader.identitylib.models.IdentityModel$Country com.sumup.merchant.reader.identitylib.models.IdentityModel$Business.getCountry()' on a null object reference
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4060)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4247)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2613)
       at android.os.Handler.dispatchMessage(Handler.java:110)
       at android.os.Looper.loop(Looper.java:219)
       at android.app.ActivityThread.main(ActivityThread.java:8668)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'com.sumup.merchant.reader.identitylib.models.IdentityModel$Country com.sumup.merchant.reader.identitylib.models.IdentityModel$Business.getCountry()' on a null object reference
       at com.sumup.merchant.reader.identitylib.models.IdentityModel.getServerCurrencyCode(SourceFile:188)
       at com.sumup.merchant.reader.models.OrderModel.getCurrency(SourceFile:248)
       at com.sumup.merchant.reader.models.AffiliateModel.getErrorMessageForApiInformation(SourceFile:244)
       at com.sumup.merchant.reader.ui.activities.CardReaderPaymentAPIDrivenPageActivity.validateApiInformation(SourceFile:235)
       at com.sumup.merchant.reader.ui.activities.CardReaderPaymentAPIDrivenPageActivity.onSafeCreate(SourceFile:150)
       at com.sumup.merchant.reader.ui.activities.SumUpReaderModuleBaseActivity.onCreate(SourceFile:50)
       at android.app.Activity.performCreate(Activity.java:8214)
       at android.app.Activity.performCreate(Activity.java:8202)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4033)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4247)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2613)
       at android.os.Handler.dispatchMessage(Handler.java:110)
       at android.os.Looper.loop(Looper.java:219)
       at android.app.ActivityThread.main(ActivityThread.java:8668)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)