TypeError: null is not an object (evaluating '_NativeStripeSdk.default.initialise') 同时在 React Native 应用程序中集成条带

问题描述

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

TypeError: null is not an object (evaluating '_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>
  );
};

这是我得到的错误

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)

这是我的 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"
    ]
  }
}

安卓模拟器错误

android模拟器中的调用

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)