@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.
@captainalbert did you find a solution for
.69?
Yes. What I do whenever I encounter this are the ff steps:
- Clean android build folder by doing a cd android & ./gradlew clean
- Delete node modules
- Reinstall node modules
and the project will run fine again in my case.
I Have the same issues, React Native : 0.75
no previous solution worked
I'm able to fix my case. i run npx react-native config to see the exact issue that i was facing and saw this error Failed to build the app: No package name found. Found errors in /Volumes/Data/ReactNativeProjects/GitHub/butl-driver-v1/node_modules/react-native-gesture-handler/android/src/main/AndroidManifest.xml. so i went straight to the path above and added the package name for the library Example: "com.swmansion.gesturehandler" After that i'm able to run the project by npm run android. Hope my solution might help. RN 0.69.3
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
Having same problem on 0.74.5
I have this problem on 0.75.4
BUİLD FAILED in 331ms error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * Where: Script '/Users/minik/FishCep/root/mobile/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 418 * What went wrong: Could not compile script '/Users/minik/FishCep/root/mobile/node_modules/@react-native-community/cli-platform-android/native_modules.gradle'.
startup failed: script '/Users/minik/FishCep/root/mobile/node_modules/@react-native-community/cli-platform-android/native_modules.gradle': 418: [Static type checking] - No such property: inputStream for class: java.lang.Process @ line 418, column 31. def output = process.inputStream.text.trim() ^ script '/Users/minik/FishCep/root/mobile/node_modules/@react-native-community/cli-platform-android/native_modules.gradle': 418: [Static type checking] - No such property: text for class: java.lang.Object @ line 418, column 43. f output = process.inputStream.text.trim ^ script '/Users/minik/FishCep/root/mobile/node_modules/@react-native-community/cli-platform-android/native_modules.gradle': 418: [Static type checking] - Cannot find matching method java.lang.Object#trim(). Please check if the declared type is correct and if the method exists. @ line 418, column 24. def output = process.inputStream.text.trim() ^ 3 errors * Try:
I thought the issues would be similar. Is there any solution?
same with react-native-maps
abdallah at buddy in ~/Data/work/trips/tale3 (main)
$ cd android && ./gradlew clean && cd ..
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* Where:
Script '/home/abdallah/Data/work/trips/tale3/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 450
* What went wrong:
A problem occurred evaluating script.
> Calling `[node, /home/abdallah/Data/work/trips/tale3/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
same issue
anyone solved it with rn70.8
any progress in this issue?
Same issue for me too
Upgrading from RN 74 to 75 I now also have this.
* Where:
Settings file '/Users/techprod/Projects/nativeapp/android/settings.gradle' line: 3
* What went wrong:
A problem occurred evaluating settings 'android'.
> ERROR: autolinkLibrariesFromCommand: process npx @react-native-community/cli config exited with error code: 126
Line 3:
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
@react-native-camera-roll/camera-roll
Check whether third-party libraries like this are referenced. The mainfast files of these third-party libraries do not have package="com.reactnativecommunity.cameraroll" which causes compilation errors. It is very annoying. You need to check them one by one.
same issue
here is my code: apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
and I don't have this file (native_modules.gradle) or folder in my node_modules
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 config
It 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.
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.
Very helpful this information.
Another tip: Check if the version installed of the package which react-native config reports is compatible with the version of your React Native installed.
For example, my React Native was 0.70.8 and both react-native-screens and react-native-gesture-handler are installed with more recent versions (compatible with 0.76+ according to the README.md from each project) so of course it wouldn't work. After installing the correct package versions, the react-native config error disappeared. :)
I fixed this by just installing the right version of @react-native-community/cli-platform-android
npm install @react-native-community/[email protected]
you will find much of them here https://app.unpkg.com/@react-native-community/[email protected]
@karimaswan22 npm install chottulink-rn-sdk react-native-nitro-modules after installing this packages this issue came anyone how to resolve this issue ?