@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.
FYI this StackOverflow is very similar to my issue but it is nearly 4 years old so may vary slightly. I have tried following it but if anyone can help explain or point me to more possible solutions that would be great.
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)
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?
It seems like this issue is related with the latest cli release which came with the release of react native 0.72 yesterday. Problems occurred since then for me. I did a gradlew clean, deleted node modules and deleted the android build folder.
I am also facing this issue with no solution
Im also facing the same issue... is there any fix yet for this ? Thanks
me to. Suddenly this error appeared.
Guys i have found a workaround, we changed 3 things
- Node version => 19.6.1
- NPM version => 9.4.0
- We were using Yarn, started using NPM again and started working! Not sure if this can help you guys but it worked for us!
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
Same. Impossible. Changed so many versions. It is everywhere, it does not depend on packages that you have at all.
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
Already fixed here
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 ran the command "npx.cmd --quiet react-native config" based on this StackOverflow
I wasn't returning JSON.
- I think I removed 2 lines in Gradle files from this StackOverflow
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.
- Then delete node_modules and run npm install again.
I don't understand why this happened, it was done through ALOT of trial and error but it worked. Hope this helps someone
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 ran the command "npx.cmd --quiet react-native config" based on this StackOverflow
I wasn't returning JSON.
- I think I removed 2 lines in Gradle files from this StackOverflow
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.
- Then delete node_modules and run npm install again.
I don't understand why this happened, it was done through ALOT of trial and error but it worked. Hope this helps someone
Yeah and then try to build again. It will fail
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
Already fixed here
So how it fixed ?
me too.
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 init command and say is it working for you correctly.
yarn remove react-native-image-picker Be useful to me
After discussing this issue with @cortinico, the problem is with broken backward compatibility in libraries, right now for this we have two solutions:
- Use React Native
0.71or0.72, - Downgrade libraries to the version that contains
packagefield inAndroidManfiest.xml
We'll upstream fixes for this to the older versions (0.69, 0.70) of RN soon.
After discussing this issue with @cortinico, the problem is with broken backward compatibility in libraries, right now for this we have two solutions:
- Use React Native
0.71or0.72,- Downgrade libraries to the version that contains
packagefield inAndroidManfiest.xmlWe'll upstream fixes for this to the older versions (0.69, 0.70) of RN soon.
I use react native 0.71.3. Which package version I should use to resolve this issue?
Hey @fahmiabdulyakub, you must check in your package.json what packages do you have, and then check release notes / changelog in these packages, and downgrade to version that have package field in AndroidManifest.xml.
Note: You should have fix for that as you're using 0.71, mind upgrading to the latest version of 0.71 or 0.72?