Troubleshooting
Troubleshooting
Build Errors
Error: "Could not find :n2applib-release:"
Solution: Make sure you've added the flatDir repository in your root build.gradle:
flatDir {
dirs "${rootProject.projectDir}/../node_modules/react-native-n2app/android/libs/"
}Error: "No matching variant found"
Solution: Clean and rebuild:
cd android
./gradlew clean
cd ..
rm -rf android/app/build android/build
# For Expo, also run:
npx expo prebuild --cleanRuntime Errors
"No current activity found"
Solution: This happens when trying to call N2app methods when no activity is available. Ensure you're calling methods after the app is fully loaded:
useEffect(() => {
// Wait for component to mount
const timer = setTimeout(() => {
checkSoftPos();
}, 500);
return () => clearTimeout(timer);
}, []);"SoftPOS app not installed"
Solution: Install the Neurogine SoftPOS app on your Android device. You can check installation status using:
const isInstalled = await N2app.isSoftPosInstalled();Also verify:
- The SoftPOS app package name matches the one in your
AndroidManifest.xml - The
<queries>section includes the correct package name - The
<meta-data>value matches the installed app's package name
"Cannot communicate with SoftPOS app" or "Package not visible"
Solution: Android 11+ requires the <queries> section to make other apps visible. Ensure:
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
<package android:name="com.neurogine.softpos.stage" />
</queries>- The
<queries>section is placed outside<application>but inside<manifest> - The package name matches your target SoftPOS app (production or staging)
- Rebuild the app after adding queries
Expo-Specific Issues
"Expo prebuild regenerates build.gradle"
Solution: After running expo prebuild, you need to re-add the flatDir configuration to android/build.gradle. Consider creating a custom Expo config plugin to automate this.
"AAR file not found after prebuild"
Solution: Ensure the package is properly installed before running prebuild:
rm -rf node_modules
npm install ./react-native-n2app-0.1.0.tgz
npx expo prebuild --cleanPackage Installation
"Cannot find module react-native-n2app"
Solution: Make sure the .tgz file is in your project directory and install it with the correct path:
# If the file is in project root
npm install ./react-native-n2app-0.1.0.tgz
# If the file is in a subdirectory
npm install ./path/to/react-native-n2app-0.1.0.tgz"Package version mismatch"
Solution: Remove the old package and reinstall:
npm uninstall react-native-n2app
rm -rf node_modules/react-native-n2app
npm install ./react-native-n2app-0.1.0.tgz