cli icon indicating copy to clipboard operation
cli copied to clipboard

@react-native-community/cli-platform-android Build Failed: The current character read is 'i' with an int value of 105

Open ablack34 opened this issue 3 years ago • 58 comments

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.
   

ablack34 avatar Jun 21 '23 21:06 ablack34

@captainalbert did you find a solution for .69?

Yes. What I do whenever I encounter this are the ff steps:

  1. Clean android build folder by doing a cd android & ./gradlew clean
  2. Delete node modules
  3. Reinstall node modules

and the project will run fine again in my case.

captainalbert avatar Sep 21 '24 15:09 captainalbert

I Have the same issues, React Native : 0.75
no previous solution worked

Gabrielfrahm avatar Sep 24 '24 12:09 Gabrielfrahm

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

duyrk avatar Sep 27 '24 02:09 duyrk

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

Riazalmahmud avatar Sep 29 '24 09:09 Riazalmahmud

Having same problem on 0.74.5

paramveer665 avatar Oct 02 '24 10:10 paramveer665

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?

minikdev avatar Oct 08 '24 00:10 minikdev

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


7adidaz avatar Oct 14 '24 21:10 7adidaz

same issue

Mehmood724 avatar Oct 26 '24 17:10 Mehmood724

anyone solved it with rn70.8

BilalHashmi94 avatar Nov 07 '24 13:11 BilalHashmi94

any progress in this issue?

Haseeba393 avatar Nov 27 '24 19:11 Haseeba393

Same issue for me too

joffblack avatar Dec 05 '24 13:12 joffblack

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() }

ftanzarella-eviivo avatar Dec 11 '24 08:12 ftanzarella-eviivo

@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.

RmondJone avatar Jan 22 '25 03:01 RmondJone

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

Image

Paul-Ananich avatar Apr 02 '25 11:04 Paul-Ananich

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.

kitavidavis avatar Apr 21 '25 09:04 kitavidavis

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.

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. :)

SimStm avatar Apr 23 '25 18:04 SimStm

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 avatar Apr 30 '25 14:04 karimaswan22

@karimaswan22 npm install chottulink-rn-sdk react-native-nitro-modules after installing this packages this issue came anyone how to resolve this issue ?

pratham3w avatar Aug 08 '25 05:08 pratham3w