stripe / stripe-android

Stripe Android SDK
https://stripe.com/docs/mobile/android
MIT License
1.29k stars 649 forks source link

[BUG] PhoneNumberController - java.lang.IndexOutOfBoundsException #9550

Open lpisk opened 2 weeks ago

lpisk commented 2 weeks ago

Summary

Crash on some devices when PaymentSheet is opened.

Android version

Android 8, Android 9, Android 10, Android 11, Android 12, Android 13

Impacted devices

Huawei, Samsung, Xiaomi, Lenovo Mobile

Installation method

Gradle dependency

Dependency Versions

Stripe Android SDK: 20.52.1

kotlin: stripe-android: 20.52.1 Android Gradle Plugin: 2.0.20 Gradle: 8.6

SDK classes

PaymentSheetScreenKt

Other information

Fatal Exception: java.lang.IndexOutOfBoundsException Index: 0, Size: 0

com.stripe.android.uicore.elements.PhoneNumberController$phoneNumberMinimumLength$1.invoke (PhoneNumberController.java:67) com.stripe.android.uicore.elements.PhoneNumberController$phoneNumberMinimumLength$1.invoke (PhoneNumberController.java:65) com.stripe.android.uicore.utils.StateFlowsKt$mapAsStateFlow$2.invoke (StateFlows.kt:68) com.stripe.android.uicore.utils.FlowToStateFlow.getValue (StateFlows.kt:39) com.stripe.android.uicore.utils.StateFlowsKt$combineAsStateFlow$2.invoke (StateFlows.kt:101) com.stripe.android.uicore.utils.FlowToStateFlow.getValue (StateFlows.kt:39) com.stripe.android.uicore.utils.StateFlowsKt$combineAsStateFlow$4.invoke (StateFlows.kt:118) com.stripe.android.uicore.utils.FlowToStateFlow.getValue (StateFlows.kt:39) com.stripe.android.uicore.elements.SectionController$special$$inlined$combineAsStateFlow$2.invoke (SectionController.java:211) com.stripe.android.uicore.utils.FlowToStateFlow.getValue (StateFlows.kt:39) com.stripe.android.uicore.utils.StateFlowsComposeKt$collectAsState$1$1.invoke (StateFlowsCompose.kt:44) com.stripe.android.uicore.utils.StateFlowsComposeKt.produceState (StateFlowsCompose.kt:34) com.stripe.android.uicore.utils.StateFlowsComposeKt.collectAsState (StateFlowsCompose.kt:43) com.stripe.android.link.ui.inline.LinkOptionalInlineSignupKt.LinkOptionalInlineSignup (LinkOptionalInlineSignup.kt:116) com.stripe.android.link.ui.inline.LinkOptionalInlineSignupKt.LinkOptionalInlineSignup (LinkOptionalInlineSignup.kt:81) com.stripe.android.link.ui.inline.LinkElementKt.LinkElement (LinkElement.kt:54) com.stripe.android.lpmfoundations.paymentmethod.link.LinkFormElement.ComposeUI (LinkFormElement.kt:27) com.stripe.android.ui.core.FormUIKt.FormUIElement (FormUI.kt:121) com.stripe.android.ui.core.FormUIKt.FormUI (FormUI.kt:75) com.stripe.android.paymentsheet.ui.PaymentMethodFormKt.PaymentMethodForm (PaymentMethodForm.kt:69) com.stripe.android.paymentsheet.ui.PaymentMethodFormKt.PaymentMethodForm (PaymentMethodForm.kt:40) com.stripe.android.paymentsheet.ui.PaymentElementKt.FormElement-PfoAEA0 (PaymentElement.kt:129) com.stripe.android.paymentsheet.ui.PaymentElementKt.PaymentElement (PaymentElement.kt:75) com.stripe.android.paymentsheet.ui.AddPaymentMethodKt.AddPaymentMethod (AddPaymentMethod.kt:27) com.stripe.android.paymentsheet.navigation.PaymentSheetScreen$AddFirstPaymentMethod.Content (PaymentSheetScreen.kt:279) com.stripe.android.paymentsheet.ui.PaymentSheetScreenKt$PaymentSheetContent$3$3$1.invoke (PaymentSheetScreen.kt:315) com.stripe.android.paymentsheet.ui.PaymentSheetScreenKt$PaymentSheetContent$3$3$1.invoke (PaymentSheetScreen.kt:314) androidx.compose.runtime.internal.ComposableLambdaImpl.invoke (ComposableLambda.jvm.kt:109)

androidx.compose.runtime.internal.ComposableLambdaImpl.invoke (ComposableLambda.jvm.kt:35) com.stripe.android.paymentsheet.ui.PaymentSheetScreenKt$EventReporterProvider$3.invoke (PaymentSheetScreen.kt:419) com.stripe.android.paymentsheet.ui.PaymentSheetScreenKt$EventReporterProvider$3.invoke (PaymentSheetScreen.kt:418) androidx.compose.runtime.internal.ComposableLambdaImpl.invoke (ComposableLambda.jvm.kt:109)

androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider (CompositionLocal.kt:380) com.stripe.android.paymentsheet.ui.PaymentSheetScreenKt.EventReporterProvider (PaymentSheetScreen.kt:415) com.stripe.android.paymentsheet.ui.PaymentSheetScreenKt.PaymentSheetContent (PaymentSheetScreen.kt:314) com.stripe.android.paymentsheet.ui.PaymentSheetScreenKt.PaymentSheetContent$Content (PaymentSheetScreen.kt:254) com.stripe.android.paymentsheet.ui.PaymentSheetScreenKt.PaymentSheetContent (PaymentSheetScreen.kt:272) com.stripe.android.paymentsheet.ui.PaymentSheetScreenKt.PaymentSheetScreenContent (PaymentSheetScreen.kt:196) com.stripe.android.paymentsheet.ui.PaymentSheetScreenKt$PaymentSheetScreenContent$2.invoke (PaymentSheetScreen.kt:147) com.stripe.android.paymentsheet.ui.PaymentSheetScreenKt$PaymentSheetScreenContent$2.invoke (PaymentSheetScreen.kt:75) androidx.compose.runtime.RecomposeScopeImpl.compose (RecomposeScopeImpl.java:192)

com.android.internal.os.ZygoteInit.main (ZygoteInit.java:873)

samer-stripe commented 1 week ago

Hey @lpisk! I wasn't able to re-produce this on the Android device types you listed. Could you name the specific device and Android version this bug was occurring on?

lpisk commented 1 week ago

@samer-stripe Our issue is mentioned here: https://github.com/stripe/stripe-android/pull/8971#discussion_r1697649769 Developers know about it.