faerin
faerin

Reputation: 1925

Expo + Stripe CardFormField crashes on Android build

I am implementing Stripe in my React Native (Expo) app. When testing it out with ExpoGO it works well, and so does the iOS build via Testflight. However, after building the app for Android it will crash whenever the CardFormField component (provided by Stripe) is rendered.

I have logged the errors in Sentry, and this is where it goes wrong:

Binary XML file line #5 in [censored]:layout/stripe_card_form_view: Error inflating class com.google.android.material.card.MaterialCardView

IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).

I then found this, here:

In order to use CardForm component, you need to install and configure Material Components theme in your app.

I do however fail to find information on how I am expected to comply with this requirement using Expo. Do anyone have any ideas?

I am using:

Thanks in advance for any help.

Upvotes: 0

Views: 966

Answers (1)

Justin Michael
Justin Michael

Reputation: 6520

With Expo you have a choice between managed vs. bare workflows. In order to access the build.gradle and styles.xml files to configure the Material Components theme you need to switch to a bare workflow. You need to use expo eject to create the native Android files in question.

Upvotes: 1

Related Questions