question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expo build crashes on both ios and android when using stripe-react-native

See original GitHub issue

Describe the bug App crashes on IOS emulator after app icon clicked (after I remove all stripe-react-native related imports, the app works fine). On Android emulator, it crashes when the method ‘createToken’ is called.

Have not tested it on real devices yet, but the app is working perfectly on Expo Go(Android Expo Go still crashes when calling creatToken).

To Reproduce Steps to reproduce the behavior:

Here’s the code to reproduce the bug:

import React, { useState, useEffect } from "react";
import { View, TextInput } from "react-native";
import Button from "./Button";

import {
  CardField,
  initStripe,
  createToken,
} from "@stripe/stripe-react-native";

const StripePaymentForm = () => {
  
  useEffect(() => {
    async function fetchPublishableKey() {
      initStripe({
        publishableKey: 'your publishable key here',
      });
    }

    fetchPublishableKey();
  }, []);

  const handleBtnPress = async () => {
    const res = await createToken(); // Android build crashes in this step
  };

  return (
    <View>
      <CardField
        postalCodeEnabled={true}
        placeholder={{
          number: "4242 4242 4242 4242",
        }}
        cardStyle={{
          backgroundColor: "#FFFFFF",
          textColor: "#000000",
          borderWidth: 1,
          borderRadius: 6,
          borderColor: "black",
        }}
        style={{
          width: "100%",
          height: 50,
          marginVertical: 15,
        }}
      />
      <Button
        title="Create Token"
        onPress={handleBtnPress}
      />
    </View>
  );
};

export default StripePaymentForm;

Expected behavior On IOS the app should not crash on splash screen. On Android, the createToken method should not cause the app to crash.

Desktop (please complete the following information):

  • OS: Windows 10 and Mac Big Sur

Smartphone (please complete the following information):

  • Device: IPhone 12 emulator, Pixel 3a emulator
  • OS: IOS14 and Android 11

Additional context stripe-react-native version: “@stripe/stripe-react-native”: “^0.1.4”,

Please let me know what kind of extra information you need from me in order to debug, thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:24 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
ruida-shencommented, Aug 2, 2021

One last question @ruida-shen. Are you using bare or managed workflow in expo?

I’m trying to reproduce the issue. I created a new expo app (expo 42), I installed stripe with expo install @stripe/stripe-react-native, imported StripeProvider and used it in App.tsx. After that when opening the app everything works correctly for me, is there something I’m missing here?

Maybe you are able to reproduce the issue on a fresh expo app.

I am using managed workflow. The app only crashes in standalone build, so after running the command expo build:iOS, and choose emulator. Then, after the build is done, download it and install it in iOS emulator, the app crashes

2reactions
souhecommented, Aug 10, 2021

@ruida-shen Expo doesn’t support @stripe/stripe-react-native with expo build. See the documentation here - https://docs.expo.dev/versions/latest/sdk/stripe/#standalone-apps

If you need a standalone iOS build please use EAS build. Remember to configure the stripe plugin correctly - https://docs.expo.dev/versions/latest/sdk/stripe/#config-plugin-setup-optional

@crosshat yours issue seems to be a different one. Can you please share the way you build the expo ap, error you see and expo and stripe versions? You can create a different issue for that

Read more comments on GitHub >

github_iconTop Results From Across the Web

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...
Read more >
Troubleshooting build errors and crashes
A reference for troubleshooting build errors and crashes when using EAS Build. ... For more information, see Android build process and iOS build...
Read more >
React Native SDK
Build payments into your React Native mobile app. The Stripe React Native SDK allows you to build payments into your native Android and...
Read more >
App crashing on initial load | Apple Developer Forums
My iOS app is crashing on the initial load. It's happening both in my ... I'm using Expo and React Native to build...
Read more >
Stripe React Native SDK
The Stripe React Native SDK allows you to build delightful payment experiences in your native Android and iOS apps using React Native.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found