在反应本机应用程序中集成条带时,类型错误:null不是对象(评估“_NativeStripeSdk.default.initialise”)

Abh*_*Jha 8 stripe-payments reactjs react-native react-native-stripe-api

我正在尝试使用新推出的 @stripe/stripe-react-native 包将 Stripe 支付链接到 React Native cli 电子商务应用程序,但在向 Stripe 提供程序元素提供可发布密钥时,我在 Android 模拟器中遇到错误

TypeError:null不是对象(评估'_NativeStripeSdk.default.initialise')

我尝试使用普通模板将 stripe 包与另一个新创建的 React Native cli 应用程序集成,但仍然遇到相同的错误。我还使用 React Web 应用程序检查了条带可发布密钥,它工作正常。

这是我的 App.js

import {StripeProvider} from '@stripe/stripe-react-native';
import React from 'react';
import {StyleSheet, View, Text} from 'react-native';

const App = () => {
  return (
    <StripeProvider publishableKey="pk_test_51IeDvNS......">
      <View>
        <Text>Hello World...</Text>
      </View>
    </StripeProvider>
  );
};

Run Code Online (Sandbox Code Playgroud)

这是我收到的错误

ERROR    TypeError: null is not an object (evaluating '_NativeStripeSdk.default.initialise')

This error is located at:
    in StripeProvider (at App.js:17)
    in App (at renderApplication.js:45)
    in RCTView (at View.js:34)
    in View (at AppContainer.js:106)
    in RCTView (at View.js:34)
    in View (at AppContainer.js:132)
    in AppContainer (at renderApplication.js:39)
Run Code Online (Sandbox Code Playgroud)

这是我的 package.json

{
  "name": "amazonclone",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint . --ext .js,.jsx,.ts,.tsx"
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "^1.15.4",
    "@react-native-community/checkbox": "^0.5.7",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-community/netinfo": "^6.0.0",
    "@react-native-picker/picker": "^1.16.0",
    "@react-navigation/bottom-tabs": "^5.11.11",
    "@react-navigation/native": "^5.9.4",
    "@react-navigation/stack": "^5.14.5",
    "@stripe/stripe-react-native": "^0.1.2",
    "amazon-cognito-identity-js": "^5.0.1",
    "aws-amplify": "^4.0.2",
    "aws-amplify-react-native": "^5.0.1",
    "country-list": "^2.2.0",
    "country-state-city": "^2.1.0",
    "react": "17.0.2",
    "react-native": "0.63",
    "react-native-bouncy-checkbox": "^2.1.1",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-inappbrowser-reborn": "^3.5.1",
    "react-native-reanimated": "^2.1.0",
    "react-native-safe-area-context": "^3.2.0",
    "react-native-screens": "^3.2.0",
    "react-native-vector-icons": "^8.1.0"
  },
  "devDependencies": {
    "@babel/core": "^7.14.3",
    "@babel/runtime": "^7.14.0",
    "@react-native-community/eslint-config": "^2.0.0",
    "@types/country-list": "^2.1.0",
    "@types/jest": "^26.0.23",
    "@types/react-native": "^0.64.5",
    "@types/react-test-renderer": "^17.0.1",
    "@types/zen-observable": "^0.8.2",
    "babel-jest": "^26.6.3",
    "eslint": "^7.26.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.66.0",
    "react-test-renderer": "17.0.2",
    "typescript": "^4.2.4"
  },
  "resolutions": {
    "@types/react": "^17"
  },
  "jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

安卓模拟器出错

Android模拟器中的调用堆栈