stripe-android icon indicating copy to clipboard operation
stripe-android copied to clipboard

[BUG] PaymentSheet crash on java.lang.ClassCastException: android.graphics.drawable.VectorDrawable cannot be cast to android.graphics.drawable.GradientDrawable

Open starchey opened this issue 1 year ago • 2 comments

Summary

We're seeing an occasional crash on Samsung devices when presenting the payment sheet with a payment intent.

FATAL EXCEPTION: main Process: com.ksl.android.classifieds, PID: 13363 java.lang.ClassCastException: android.graphics.drawable.VectorDrawable cannot be cast to android.graphics.drawable.GradientDrawable at m.axz.b(:com.google.android.gms.dynamite_dynamitemodulesc@[email protected] (140400-0):12) at m.axm.a(:com.google.android.gms.dynamite_dynamitemodulesc@[email protected] (140400-0):32) at com.google.android.gms.wallet.dynamite.PayButtonCreatorChimeraImpl.newPayButton(:com.google.android.gms.dynamite_dynamitemodulesc@[email protected] (140400-0):143) at m.axd.z(:com.google.android.gms.dynamite_dynamitemodulesc@[email protected] (140400-0):44) at m.ql.onTransact(:com.google.android.gms.dynamite_dynamitemodulesc@[email protected] (140400-0):21) at android.os.Binder.transact(Binder.java:1219) at com.google.android.gms.internal.wallet.zza.zzb(com.google.android.gms:play-services-wallet@@19.3.0-beta01:2) at com.google.android.gms.wallet.button.zze.zzd(com.google.android.gms:play-services-wallet@@19.3.0-beta01:4) at com.google.android.gms.wallet.button.zzf.zza(com.google.android.gms:play-services-wallet@@19.3.0-beta01:6) at com.google.android.gms.wallet.button.PayButton.initialize(com.google.android.gms:play-services-wallet@@19.3.0-beta01:17) at com.stripe.android.paymentsheet.ui.GooglePayButtonKt$ComposePayButton$2$1.invoke(GooglePayButton.kt:95) at com.stripe.android.paymentsheet.ui.GooglePayButtonKt$ComposePayButton$2$1.invoke(GooglePayButton.kt:93) at androidx.compose.ui.viewinterop.ViewFactoryHolder$updateBlock$1.invoke(AndroidView.android.kt:367) at androidx.compose.ui.viewinterop.ViewFactoryHolder$updateBlock$1.invoke(AndroidView.android.kt:367) at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2299) at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:467) at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:230) at androidx.compose.ui.viewinterop.AndroidViewHolder$runUpdate$1.invoke(AndroidViewHolder.android.kt:178) at androidx.compose.ui.viewinterop.AndroidViewHolder$runUpdate$1.invoke(AndroidViewHolder.android.kt:176) at androidx.compose.ui.viewinterop.AndroidViewHolder.setUpdate(AndroidViewHolder.android.kt:110) at androidx.compose.ui.viewinterop.ViewFactoryHolder.setUpdateBlock(AndroidView.android.kt:367) at androidx.compose.ui.viewinterop.AndroidView_androidKt$AndroidView$3$1.invoke(AndroidView.android.kt:254) at androidx.compose.ui.viewinterop.AndroidView_androidKt$AndroidView$3$1.invoke(AndroidView.android.kt:254) at androidx.compose.runtime.ComposerImpl$apply$operation$1.invoke(Composer.kt:1712) at androidx.compose.runtime.ComposerImpl$apply$operation$1.invoke(Composer.kt:1710) at androidx.compose.runtime.ComposerImpl$recordInsert$2.invoke(Composer.kt:3546) at androidx.compose.runtime.ComposerImpl$recordInsert$2.invoke(Composer.kt:3543) at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:818) at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:849) at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:625) at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:537) at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:41) at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109) at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41) at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1648) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1659) at android.view.Choreographer.doCallbacks(Choreographer.java:1129)

Code to reproduce

Inside our fragment onCreate:

paymentSheet = PaymentSheet(this, ::onPaymentSheetResult)

Then, on the action to trigger the payment sheet:

paymentSheet.presentWithPaymentIntent(
    paymentIntentClientSecret,
    PaymentSheet.Configuration(
        merchantDisplayName = "Our App",
        googlePay = PaymentSheet.GooglePayConfiguration(
            environment = if (viewModel.uiState.value.isTestEnabled) {
                PaymentSheet.GooglePayConfiguration.Environment.Test
            } else {
                PaymentSheet.GooglePayConfiguration.Environment.Production
            },
            countryCode = "US",
            currencyCode = "USD"
        ),
        appearance = PaymentSheet.Appearance(
            colorsLight = PaymentSheet.Colors.defaultLight.copy(
                primary = resources.getColor(R.color.new_blue),
            ),
            typography = PaymentSheet.Typography.default.copy(
                fontResId = R.font.nunito_sans_ttf
            )
        )
    )
)

Android version

Android 14

Impacted devices

Samsung Galaxy S23

Installation method

Gradle

Dependency Versions

kotlin: 1.9.10 stripe-android: 20.37.1 Android Gradle Plugin: 8.2.2 Gradle: 8.3

SDK classes

PaymentSheet

starchey avatar Feb 05 '24 18:02 starchey

@dmengelt This seems to be a Google Pay issue. Can you take a look?

tillh-stripe avatar Feb 05 '24 20:02 tillh-stripe

interesting. we aren't using android.graphics.drawable.VectorDrawable in our SDK.

dmengelt avatar Feb 06 '24 09:02 dmengelt

We are unable to reproduce, please reopen with steps to reproduce.

jaynewstrom-stripe avatar Jun 17 '24 17:06 jaynewstrom-stripe