Please block the button from several payment attempts if request to Braintree API is already in progress. Several payment flows are started in parallel and BraintreeFragment is detached from Activity when receive first successful payment result. Other payment results cause this crash.
java.lang.IllegalStateException: Fragment must be attached to an activity.
at com.braintreepayments.browserswitch.BrowserSwitchClient.start(BrowserSwitchClient.java:206) ~[na:0.0]
at com.braintreepayments.browserswitch.BrowserSwitchClient.start(BrowserSwitchClient.java:186) ~[na:0.0]
at com.braintreepayments.browserswitch.BrowserSwitchFragment.browserSwitch(BrowserSwitchFragment.java:59) ~[na:0.0]
at com.braintreepayments.api.ThreeDSecure.continuePerformVerification(ThreeDSecure.java:266) ~[na:0.0]
at com.braintreepayments.api.ThreeDSecure$3.onLookupComplete(ThreeDSecure.java:155) ~[na:0.0]
at com.braintreepayments.api.ThreeDSecure$7.success(ThreeDSecure.java:503) ~[na:0.0]
at com.braintreepayments.api.internal.HttpClient$3.run(HttpClient.java:288) ~[na:0.0]
at android.os.Handler.handleCallback(Handler.java:739) ~[na:0.0]
at android.os.Handler.dispatchMessage(Handler.java:95) ~[na:0.0]
at android.os.Looper.loop(Looper.java:157) ~[na:0.0]
at android.app.ActivityThread.main(ActivityThread.java:5429) ~[na:0.0]
at java.lang.reflect.Method.invoke(Native Method) ~[na:0.0]
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) ~[na:0.0]
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) ~[na:0.0]
General information
SDK/Library version: Android SDK 4.0.1
Environment: Development
Android Version and Device: All Android versions with various devices
Braintree dependencies:
com.braintreepayments.api:braintree:3.14.0
com.braintreepayments.api:drop-in:4.6.0
com.braintreepayments.api:google-payment:3.3.1
Issue description
The issue is related to https://github.com/braintree/braintree_android/issues/308. Firstly we observed crash from the #308 and now after fixes crash happens in next step by code, when BrowserSwitchOptions.start is called:
ThreeDSecure:
BrowserSwitchFragment:
BrowserSwitchClient:
The issue can be reproduced by the following steps:
Please block the button from several payment attempts if request to Braintree API is already in progress. Several payment flows are started in parallel and BraintreeFragment is detached from Activity when receive first successful payment result. Other payment results cause this crash.