I am trying to link stripe payment to a react native cli ecommerce app using the newly launched @stripe/stripe-react-native package but i am getting an error in android simulator while providing publishable key to stripe provider element
TypeError: null is not an object (evaluating '_NativeStripeSdk.default.initialise')
I tried to integrate the stripe package with another newly created react native cli app with just a normal template but still I am getting the same error. I have also checked the stripe publishable key with a react web app and it is working fine.
Here is my 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>
);
};
Here is the error I am getting
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)
Here is my 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"
]
}
}
error in android simulator

call stack in android simulator

There are a few things you can try to troubleshoot this issue:
Make sure that you have correctly imported the StripeProvider component from the @stripe/stripe-react-native package and that you have provided a valid Stripe publishable key as the publishableKey prop.
Make sure that you have properly installed the @stripe/stripe-react-native package and that it is listed in your package.json file as a dependency.
Try installing the @stripe/stripe-react-native package again, just in case there was an issue with the initial installation.
If you are using an Android emulator, try running your app on a physical Android device to see if that resolves the issue.
Check the logs in your emulator or device to see if there are any additional error messages that might provide more context on what is causing the issue.
Make sure that you have correctly configured the native dependencies for the @stripe/stripe-react-native package. You can find instructions on how to do this in the package's documentation: https://github.com/stripe/stripe-react-native.