I am working on a bare React Native app and I’m using the RN plugin for the in-app-payments SDK. Right now, I’m trying to set up the SDK on the Android side by following the Github guide. I’ve made sure the app is meeting the Android requirements, minSdkVersion = 28, but the current code:
is throwing the error [TypeError: Cannot read property 'setApplicationId' of null] on initial render.
And when I try to call onStartCardEntry(), I get TypeError: Cannot read property 'startCardEntryFlow' of null.
Appreciate any help!
I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:
If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.
It seems like the Square In-App Payments SDK is not properly linked to your React Native project. The error messages indicate that the SDK methods you’re trying to call are not recognized, which usually happens when the SDK is not correctly installed or linked.
In React Native, you need to ensure that the native modules of the SDK are properly linked to your project. If you’re using React Native 0.60 or above, the linking should be automatic thanks to auto-linking feature. However, you might need to perform manual linking if you’re using an older version of React Native.
Also, make sure you have followed all the installation steps correctly as mentioned in the official Square documentation. This includes adding the necessary dependencies in your build.gradle file, setting up your Square Application ID, and so on.
If you’ve done all these and the issue persists, you might want to try cleaning your project and rebuilding it. Sometimes, the build cache can cause issues with newly installed dependencies.
Hey managed to fix it and thanks for the help. It was a configuration issue and when I tried building the app I would get this error could not find com.squareup.sdk.in-app-payments:card-entry:1.6.5. My app’s gradle version was 8.0.1 and I fixed both this error and the one above by downgrading it to 7.5.