stripe / stripe-identity-react-native

React Native library for Stripe Identity
https://stripe.dev/stripe-identity-react-native
MIT License
33 stars 7 forks source link

[Android] Crash useStripeIdentity present() #153

Closed talentipper closed 8 months ago

talentipper commented 8 months ago

Following these instructions causes the app to crash when presenting stripe identity verification on Android (works on iOS): https://stripe.dev/stripe-identity-react-native/api-reference/index.html#getting-started

const { status, present, loading } = useStripeIdentity(fetchOptions);

  const handlePress = useCallback(() => {
    present();
  }, [present]);

  const renderButton = useCallback(() => {
    if (loading) {
      return <ActivityIndicator />;
    }
    return <Button title="Verify Identity" onPress={handlePress} />;
  }, [loading, handlePress]);

  return (
    <View>
      <View>{renderButton()}</View>
      <Text>Status: {status}</Text>
    </View>
  );

"@stripe/stripe-identity-react-native": "^0.2.5" "react-native": "0.73.4"

Get the following logs:

02-22 22:29:55.302 27638 27638 E AndroidRuntime: FATAL EXCEPTION: main
02-22 22:29:55.302 27638 27638 E AndroidRuntime: Process: com.talentipper.TalenTipper, PID: 27638
02-22 22:29:55.302 27638 27638 E AndroidRuntime: java.lang.IllegalArgumentException: createMdcTheme requires the host context's theme to extend Theme.MaterialComponents
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at com.google.accompanist.themeadapter.material.MdcTheme.createMdcTheme(MdcTheme.kt:173)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at com.google.accompanist.themeadapter.material.MdcTheme.createMdcTheme$default(MdcTheme.kt:162)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at com.stripe.android.identity.ui.IdentityThemeKt.IdentityTheme(IdentityTheme.kt:38)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at com.stripe.android.identity.IdentityActivity$onCreate$4.invoke(IdentityActivity.kt:184)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at com.stripe.android.identity.IdentityActivity$onCreate$4.invoke(IdentityActivity.kt:180)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:428)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:252)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:251)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:195)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:119)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:118)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:110)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:158)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:157)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:157)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:142)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:78)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3340)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3273)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:588)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:1013)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:520)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:142)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:133)
02-22 22:29:55.302 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1191)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:133)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:183)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:322)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:199)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:140)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:133)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1266)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.View.dispatchAttachedToWindow(View.java:21991)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3493)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3500)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3500)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3500)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3500)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3500)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3500)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3198)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2650)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9526)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1343)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1352)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.Choreographer.doCallbacks(Choreographer.java:952)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.Choreographer.doFrame(Choreographer.java:882)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1326)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:958)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:205)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:294)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:8248)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
02-22 22:29:55.304 27638 27638 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
02-22 22:29:55.313  1690  3906 W ActivityTaskManager:   Force finishing activity com.talentipper.TalenTipper/com.stripe.android.identity.IdentityActivity
02-22 22:29:55.313  1690 28164 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
02-22 22:29:55.314  1690  3906 W ActivityTaskManager:   Force finishing activity com.talentipper.TalenTipper/.MainActivity
02-22 22:29:55.317 27638 27638 I Process : Sending signal. PID: 27638 SIG: 9
talentipper commented 8 months ago

Missing @pchmn/expo-material3-theme was the issue outlined here: https://github.com/stripe/stripe-identity-react-native/blob/main/README.md

cSieves commented 2 months ago

Hey @talentipper did you manage to get this working? I have installed @pchmn/expo-material3-theme in my app but am still seeing the same issue. Do I need to configure something? My understanding of using the library is that simply installing it should be enough but I am still seeing the underlying error?