braintree-android-drop-in: NullPointerExceptions In cardinalmobilesdk
General information
- SDK/Library version: 6.0.0
- Environment: Production
- Android Version and Device: Android 11 (LG V60 ThinQ)
Issue description
I’ve been getting some crash reports from Crashlytics about this issue.
The crash occurred in the cardinalcommerce library. ChallengeUtils.java line 2
com.cardinalcommerce.shared.cs.userinterfaces.ChallengeUtils.a
The Crashlytics report claims the device was in Landscape so I reckon the user went through a configuration change. Looking at the issue with the NullPointer with Context, I am going to assume the cardinalcommerce is holding onto a Context reference and calling getApplicationContext() on a reference that is no longer present during config change.
Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:415)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
at com.cardinalcommerce.shared.cs.userinterfaces.ChallengeUtils.a(ChallengeUtils.java:2)
at com.cardinalcommerce.shared.cs.userinterfaces.ChallengeUtils.a(ChallengeUtils.java:41)
at com.cardinalcommerce.shared.cs.f.m.a(m.java:46)
at com.cardinalcommerce.cardinalmobilesdk.a.c.d.a(d.java:84)
at com.cardinalcommerce.shared.cs.d.a.a(a.java:191)
at com.cardinalcommerce.shared.cs.d.a.doInBackground(a.java:2)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
I also got another crash report, one second later from the same device. I decided to combine them rather than raise a separate issue because I think they are related. I guess this may have been the Activity behind the one above which tries to perform the challenge which also crashed.
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wam.android/com.braintreepayments.api.ThreeDSecureActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String r6.f.e()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3472)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3636)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
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:2084)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7887)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String r6.f.e()' on a null object reference
at com.cardinalcommerce.cardinalmobilesdk.a.a.a.a(a.java:318)
at com.cardinalcommerce.cardinalmobilesdk.Cardinal.cca_continue(Cardinal.java:2)
at com.braintreepayments.api.CardinalClient.continueLookup(CardinalClient.java:44)
at com.braintreepayments.api.ThreeDSecureActivity.onCreateInternal(ThreeDSecureActivity.java:39)
at com.braintreepayments.api.ThreeDSecureActivity.onCreate(ThreeDSecureActivity.java:28)
at android.app.Activity.performCreate(Activity.java:8019)
at android.app.Activity.performCreate(Activity.java:8003)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1310)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3445)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3636)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
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:2084)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7887)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
I’d be happy to provide more implementation details but not sure what would be useful since the stacktrace refers to obfuscated properties and methods. Let me know what would be of help here. Thank you
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (6 by maintainers)
all good here too thanks @sshropshire 😃
@ersen-lw @m-s-morgan @soarb maybe
ThreeDSecureActivityin the Braintree SDK needs to useTheme.AppCompat. I made this PR and once it’s approved we’ll update the core dependency in this repo to update DropIn. We can see if this helps resolve the issue.@sshropshire
@ersen-lw @m-s-morgan @soarb
ThreeDSecureActivitynow usesTheme.AppCompatin the latest 6.8.0 version. Please reply here if the issues persists (or is resolved 🤞).@sarahkoop this is a critical issue for our team at the moment and I just want to make sure this thread is still being monitored. Thank you in advance.