cli: @react-native-community/cli-platform-android Build Failed: The current character read is 'i' with an int value of 105
I was building, running and demoing my app at 11:30am this morning using npx react-native run-android, I made a PR and merged my branch into Dev an hour later. The build failed with the error below. I thought this was odd so in my local I deleted node_modules and package-lock.json, ran cd android && ./gradlew clean, then cd… and npx react-native run-android. My local started producing this same error. I have no idea what could have changed or what would have caused this.
I have been googling and trying different solutions with no success and a deadline looming. Can anybody help guide me to a solution please? TIA!
Environment
react-native info
System:
OS: Windows 10 10.0.22621
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Memory: 10.99 GB / 31.85 GB
Binaries:
Node: 16.18.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Not Found
Visual Studio: 17.5.33627.172 (Visual Studio Enterprise 2022)
Languages:
Java: 11.0.16.1
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: 0.70.7 => 0.70.7
react-native-windows: Not Found
npmGlobalPackages:
*react-native*: Not Found
**react-native --version**
react-native-cli: 2.0.1
react-native: 0.70.7
Description
npx react-native run-android
warn Package react-native-sqlite-storage contains invalid configuration: "dependency.platforms.ios.project" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
info Starting JS server...
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\Public\xyz\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 450
* What went wrong:
A problem occurred evaluating script.
> Calling `[node, C:\Users\Public\xyz\node_modules\@react-native-community\cli\build\bin.js, config]` finished with an exception. Error message: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
The current character read is 'i' with an int value of 105
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
info Run CLI with --verbose flag for more details.
^. Output: info Run CLI with --verbose flag for more details.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\Public\xyz\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 450
* What went wrong:
A problem occurred evaluating script.
> Calling `[node, C:\Users\Public\xyz\node_modules\@react-native-community\cli\build\bin.js, config]` finished with an exception. Error message: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
The current character read is 'i' with an int value of 105
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
info Run CLI with --verbose flag for more details.
^. Output: info Run CLI with --verbose flag for more details.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s
at makeError (C:\Users\Public\xyz\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at C:\Users\Public\xyz\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (C:\Users\Public\xyz\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\Public\xyz\node_modules\@react-native-community\cli\build\index.js:142:9)
info Run CLI with --verbose flag for more details.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 21
- Comments: 57 (2 by maintainers)
I found the solution to RN cli issues specifically for older RN versions as pointed by @nhokmoon. I am using RN 68.7. I added
resolutionsto mypackage.jsonto force use older RN CLI versions:And now the Android build is succeeding 🚀.
Check the compatible version of RN CLI version for your RN version: https://github.com/react-native-community/cli?tab=readme-ov-file#compatibility
I am also facing this issue with no solution
The solution is node_modules@react-native-community\cli-platform-android\native_modules.gradle’ line: 401 => yarn cache clean => npm install -g react-native-cli => npx react-native doctor => yarn global add @react-native-community/cli => npx expo prebuild => yarn expo run:android
I Have the same issues,
React Native : 0.75no previous solution worked
For me it was caused by
react-native-image-picker. Updating it fixed itAfter discussing this issue with @cortinico, the problem is with broken backward compatibility in libraries, right now for this we have two solutions:
0.71or0.72,packagefield inAndroidManfiest.xmlWe’ll upstream fixes for this to the older versions (0.69, 0.70) of RN soon.
I fixed this by just installing the right version of @react-native-community/cli-platform-android
npm install @react-native-community/cli-platform-android@15.0.0
you will find much of them here https://app.unpkg.com/@react-native-community/cli-platform-android@15.0.0
@nhokmoon , did you fix the issue? i’ve been stuck for days now.
npx react-native run-android --variant=devDebug info Running jetifier to migrate libraries to AndroidX. You can disable it using “–no-jetifier” flag. Jetifier found 2993 file(s) to forward-jetify. Using 8 workers… info Starting JS server… info Launching emulator… error Failed to launch emulator. Reason: Emulator exited before boot… warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch. info Installing the app… :ReactNative:Running ‘[node, -e, try {console.log(require(’@react-native-community/cli’).bin);} catch (e) {console.log(require(‘react-native/cli’).bin);}]’ command failed.
FAILURE: Build failed with an exception.
Where: Script ‘C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules@react-native-community\cli-platform-android\native_modules.gradle’ line: 397
What went wrong: A problem occurred evaluating script.
BUILD FAILED in 2s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Error: Command failed: gradlew.bat app:installDevDebug -PreactNativeDevServerPort=8081 :ReactNative:Running ‘[node, -e, try {console.log(require(’@react-native-community/cli’).bin);} catch (e) {console.log(require(‘react-native/cli’).bin);}]’ command failed.
FAILURE: Build failed with an exception.
Where: Script ‘C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules@react-native-community\cli-platform-android\native_modules.gradle’ line: 397
What went wrong: A problem occurred evaluating script.
BUILD FAILED in 2s
info Run CLI with --verbose flag for more details.
C:\Users\nhung\Desktop\soba\src\Soba-MobileApp>./gradlew clean ‘.’ is not recognized as an internal or external command, operable program or batch file.
C:\Users\nhung\Desktop\soba\src\Soba-MobileApp>cd android
C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\android>./gradlew clean ‘.’ is not recognized as an internal or external command, operable program or batch file.
C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\android>gradlew clean
Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for details :ReactNative:Running ‘[node, -e, try {console.log(require(’@react-native-community/cli’).bin);} catch (e) {console.log(require(‘react-native/cli’).bin);}]’ command failed.
FAILURE: Build failed with an exception.
Where: Script ‘C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules@react-native-community\cli-platform-android\native_modules.gradle’ line: 397
What went wrong: A problem occurred evaluating script.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 5s how to fix this i’m stuck for 2 day
1.rm -fr node_modules 2.yarn install 3.yarn react-native run-android
Im also facing the same issue… is there any fix yet for this ? Thanks
I found a solution to this. It is similar to @duyrk , except that we need to be aware the package might be missing in other dependencies as well. On my case, the packageName was missing on a react-native-screens dependency. So, to fully sort this issue, you first need to identify which dependency has a package issue. Run the following command:
node ./node_modules/@react-native-community/cli/build/bin.js configIt should return something like this:
error Failed to build the app: No package name found. Found errors in <root-path>\node_modules\react-native-screens\android\src\main\AndroidManifest.xml.With that, you’ve narrowed your problem. Just navigate to the xml file and add the correct package. Note that I also downgraded my node version to 18.
Same issue for me too
Hi, were you able to upstream the fix for .69?
Im Using 0.73 Facing Same Issue, but I also some more error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 Script ‘E:\Final Year Project\Phase 2\Application\React Native App\DairyPureApp\node_modules@react-native-community\cli-platform-android\native_modules.gradle’ line: 401 :ReactNative:Running ‘[node, E:\Final Year Project\Phase 2\Application\React Native App\DairyPureApp\node_modules@react-native-community\cli\build\bin.js, config]’ command failed.
@szymonrybczak something to add to #1983 ?
Hello 👋 This is probably not issue related to React Native CLI - but related to libraries, please try upgrading (such as react-native-image-picker or react-native-cameraroll or any other) - probably in these libraries were introduced breaking change that breaks your app. Please also try creating fresh React Native app with
npx react-native@latest initcommand and say is it working for you correctly.I don’t understand how or why, but I removed “react-native-image-picker”: “^5.0.1” and it started to build again.
How got to removing this package:
I wasn’t returning JSON.
And that revealedan error that there was something missing in the AndroidManifest.xml of the react-native-image-picker package. I wasn’t using this package as it was an artifact from a previous phase so was just able to remove it.
I don’t understand why this happened, it was done through ALOT of trial and error but it worked. Hope this helps someone
same issue here, it only works when I do delete node_modules and yarn install again but the error will appear again if I run the second build (yarn react-native run-android), which means I must delete node_modules and yarn install again every single time I want to develop/build the app. I found this issue when i add react-native-cameraroll
I’ve already tried it on my both device which is Windows 11 and MacOS Ventura 13.3.1 and the issue is still the same
Guys i have found a workaround, we changed 3 things
When did this error start for you? I’ve tried rolling back to previous commits and re-cloning to an earlier version of the app I’m still facing the same error.
Could you talk me through you clean install process please?
i’m experiencing the same issue since upgrading a dependency. I’ve also tried a clean install, downgrading the dependencies, further upgrading them but i can’t the app running. (Can also confirm this on various apps)