I’m integrating the Square Mobile Payments SDK using the mobile-payments-sdk-react-native
package in my React Native project. After following the setup instructions and configuring the necessary files for both Android and iOS, I attempted to run the app but encountered build failures. On Android, the Kotlin compiler throws errors related to missing parameters (processingMode
) and attempts to access a private property in the SDK’s Utils.kt
file. Additionally, there’s a StackOverflowError
during the build process, along with deprecation warnings. These issues are preventing the app from running on both platforms, and I’m looking for guidance on how to resolve them or correctly configure the SDK.
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:
Additional Documentation
Install the In-App Payments SDK
In-App Payments SDK: How It Works
React Native Plugin: In-App Payments SDK
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.
i try to integrate mobile-payments-sdk-react-native.
What’s your application ID? Also do you have any of our other SDKs in the app? If so it will cause build failures. Additionally here are some other troubleshooting steps:
For Android, ensure that your application’s minSdkVersion
is API 24 (Android 7) or later, and your targetSdkVersion
is API 34 (Android 14) or earlier. Your application’s compileSdkVersion
should be 34. Also, make sure you’re using Android Gradle Plugin version 8.4.2 or later.
For iOS, ensure that your application targets iOS 16 or later. Also, make sure you’re not using Proguard for code optimization as compressing the Mobile Payments SDK binary removes critical bytecode elements and results in runtime errors. If you’re still encountering issues, it might be helpful to clean and rebuild your project.
For Android, you can do this by running ./gradlew clean
followed by ./gradlew assembleDebug
.
For iOS, you can clean your project by selecting Product > Clean Build Folder
in Xcode.
I’m running of below version and i think it’s not compatible 0.71.2 with Android Gradle Plugin (AGP) 8.4.2. Could you pls help me how can migrate Square SDK to mobile-payments-sdk-react-native ?
“react”: “18.2.0”,
“react-native”: “0.71.3”,
@Bryan-Square this is the exact issue we are facing as well. Any help will be much appreciated as the selling season is fast approaching.
Using Android Gradle Plugin (AGP) 8.4.2 is a requirement with Mobile Payments SDK. If you must you’ll need to update to support Android Gradle Plugin (AGP) 8.4.2.
@Bryan-Square So, can we use AGP 8.4.2 in react native 0.71.3 version ?
As far as I know React Native 0.71.3 officially supports:
- Android Gradle Plugin (AGP) version 7.3.1
- Gradle version 7.5.1
Using AGP 8.4.2 with React Native 0.71.3 is not recommended because:
- AGP 8.x introduces breaking changes in the build system
- React Native 0.71.3 was not designed to work with AGP 8.x
- You may encounter build failures and compatibility issues
I have integrated Square with React Native version 0.75.3 and followed every step, including successful authorization. However, when attempting to connect to the Square Reader, it fails and shows the error in the screenshot below.
Are you in developer mode?
how can i check developer mode ?
What’s your application ID?
here is my application id
sq0idp-KFRykXN3sdk7LbMr8WY8pw
Are you still using React Native 0.71.3?
I’m encountering an error during authentication on iOS using React Native (react-native
version 0.75.3
) in both real device and simulator. It works fine on Android.
I took a look at your logs and it looks like your calling CreateMobileAuthorizationCode
. Is there a reason your using that endpoint? That’s just for Reader SDK, not Mobile Payments SDK.
I’m currently encountering an issue while attempting to authorize the Square token on iOS device. Previously, our app successfully integrated with the Square Reader. We’re now in the process of migrating to the mobile-payments-sdk-react-native
library, using React Native version 0.75.3.
While the integration is working smoothly on Android, iOS consistently fails during the authorization step. We would greatly appreciate your assistance in identifying and resolving this issue as soon as possible.
Please let me know if you need additional logs or configuration details.
this is code to attempting for authorization.
const handleAuthorize = async () => {
setIsLoading(true);
let squareCode = global.sqaureToken;
try {
let auth = await authorize(squareCode, BuildConfig.LOCATION_ID);
let authorizedLocation = await getAuthorizedLocation();
let authorizationState = await getAuthorizationState();
setIsAuthorized(true);
Utility.log(
'SDK Authorized with location ’ + JSON.stringify(authorizedLocation)
);
Utility.log(
'SDK Authorization Status is ’ + JSON.stringify(authorizationState)
);
} catch (error) {
setIsAuthorized(false);
Utility.log('Authorization error: ', JSON.stringify(error));
Alert.alert(‘Error Authenticating’, error.message);
}
setIsLoading(false);
};
Note: Here is official steps that i had followed.
What’s your application ID, location_id
that your trying to authorize and whats the timestamp with timezone that this happened.
Hi Bryan
Thank you for your response. I can answer this:
App ID: sq0idp-KFRykXN3sdk7LbMr8WY8pw
Location ID: LAJXDFV4WF19F - Pyro Mart Inc
but this happens at all of our subsidiary locations as well
Timestamp would be 5:23PM EST (I just ran this with the same error) “Error Authenticating - The server returned an unexpected response, please try again later”
Thank you for what you do Bryan!
Also, the selling season starts in 5 days so…anything we can do to expedite this will be much appreciated