Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ablack34 opened this issue Jun 21, 2023 · 47 comments
Labels
question Further information is requested

Comments

@ablack34
Copy link

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 ablack34 added the question Further information is requested label Jun 21, 2023
@ablack34
Copy link
Author

ablack34 commented Jun 21, 2023

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.

@Ritorna
Copy link

Ritorna commented Jun 22, 2023

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)

@ablack34
Copy link
Author

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?

@Ritorna
Copy link

Ritorna commented Jun 22, 2023

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.

@ttshivhula
Copy link

I am also facing this issue with no solution

@jlora-mck
Copy link

Im also facing the same issue... is there any fix yet for this ? Thanks

@OFD16
Copy link

OFD16 commented Jun 27, 2023

me to. Suddenly this error appeared.

@jlora-mck
Copy link

jlora-mck commented Jun 27, 2023

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!

@VEmpink
Copy link

VEmpink commented Jun 28, 2023

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

@dr1verrr
Copy link

dr1verrr commented Jun 28, 2023

Same. Impossible. Changed so many versions. It is everywhere, it does not depend on packages that you have at all.

@VEmpink
Copy link

VEmpink commented Jun 29, 2023

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

@ablack34
Copy link
Author

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

@dr1verrr
Copy link

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

@dr1verrr
Copy link

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 ?

@dalaocu
Copy link

dalaocu commented Jul 5, 2023

me too.

@szymonrybczak
Copy link
Collaborator

szymonrybczak commented Jul 7, 2023

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.

@Zc0412
Copy link

Zc0412 commented Jul 17, 2023

yarn remove react-native-image-picker
Be useful to me

@szymonrybczak
Copy link
Collaborator

After discussing this issue with @cortinico, the problem is with broken backward compatibility in libraries, right now for this we have two solutions:

  1. Use React Native 0.71 or 0.72,
  2. Downgrade libraries to the version that contains package field in AndroidManfiest.xml

We'll upstream fixes for this to the older versions (0.69, 0.70) of RN soon.

@fahmiabdulyakub
Copy link

After discussing this issue with @cortinico, the problem is with broken backward compatibility in libraries, right now for this we have two solutions:

  1. Use React Native 0.71 or 0.72,
  2. Downgrade libraries to the version that contains package field in AndroidManfiest.xml

We'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?

@szymonrybczak
Copy link
Collaborator

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?

@fahmiabdulyakub
Copy link

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?

I still confuse about that solution. This my package.json and AndroidManifest.xml. What I'm suppose to do ?

{
  "name": "MyApp",
  "version": "2.1.3",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint . --ext .js,.jsx,.ts,.tsx",
    "gradleclear": "cd android && bash gradlew clean && cd ../",
    "android:stage": "react-native run-android --variant=stagingDebug",
    "android:stage-release": "react-native run-android --variant=stagingRelease",
    "android:ip": "react-native run-android --variant=ipDebug",
    "android:ip-release": "react-native run-android --variant=ipRelease",
    "android:prod": "react-native run-android --variant=productionDebug",
    "android:prod-release": "react-native run-android --variant=productionRelease",
    "buildapk:stage": "cd android && bash gradlew clean && bash gradlew app:assembleStagingRelease && cd ../",
    "buildapk:ip": "cd android && bash gradlew clean && bash gradlew app:assembleIpRelease && cd ../",
    "buildapk:prod": "cd android && bash gradlew clean && bash gradlew app:assembleProductionRelease && cd ../",
    "buildbundle:aab": "cd android && bash gradlew clean && bash gradlew bundleProductionRelease && cd ../"
  },
  "dependencies": {
    "@apollo/client": "^3.7.10",
    "@notifee/react-native": "^7.0.4",
    "@myapp/react-native-calendar-picker": "^1.0.14",
    "@myapp/uikit-mobile": "^0.0.95",
    "@react-native-community/blur": "^4.3.2",
    "@react-native-community/cli": "^10.1.3",
    "@react-native-community/cli-platform-android": "^10.0.0",
    "@react-native-community/clipboard": "^1.5.1",
    "@react-native-community/datetimepicker": "^7.0.0",
    "@react-native-community/netinfo": "^9.3.6",
    "@react-native-firebase/analytics": "^17.4.2",
    "@react-native-firebase/app": "^17.4.2",
    "@react-native-firebase/crashlytics": "^17.4.2",
    "@react-native-firebase/dynamic-links": "^17.4.2",
    "@react-native-firebase/messaging": "^17.4.2",
    "@react-native-picker/picker": "^2.4.8",
    "@react-navigation/bottom-tabs": "^6.5.7",
    "@react-navigation/native": "^6.1.6",
    "@react-navigation/native-stack": "^6.8.0",
    "@react-navigation/stack": "^6.3.16",
    "@reduxjs/toolkit": "^1.8.5",
    "apollo-link-rest": "^0.9.0",
    "axios": "^0.27.2",
    "babel-plugin-module-resolver": "^4.1.0",
    "base-64": "^1.0.0",
    "dayjs": "^1.11.5",
    "deprecated-react-native-prop-types": "^4.0.0",
    "hermes-engine": "^0.11.0",
    "i": "^0.3.7",
    "i18next": "^21.9.1",
    "install": "^0.13.0",
    "lodash": "^4.17.21",
    "lottie-ios": "^3.2.3",
    "moment": "^2.29.1",
    "moment-timezone": "^0.5.40",
    "native-base": "^3.4.20",
    "npm": "^8.19.4",
    "react": "18.2.0",
    "react-i18next": "^11.18.5",
    "react-native": "0.71.3",
    "react-native-bluetooth-escpos-printer": "^0.0.5",
    "react-native-calendar-picker": "^7.1.2",
    "react-native-camera": "^4.2.1",
    "react-native-cli": "^2.0.1",
    "react-native-code-push": "^8.0.2",
    "react-native-config": "^1.4.11",
    "react-native-device-info": "^10.6.0",
    "react-native-encrypted-storage": "^4.0.2",
    "react-native-fbsdk-next": "^11.2.1",
    "react-native-gesture-handler": "^2.9.0",
    "react-native-get-random-values": "^1.8.0",
    "react-native-html-to-pdf": "^0.12.0",
    "react-native-image-crop-picker": "^0.39.0",
    "react-native-image-picker": "^4.10.0",
    "react-native-in-app-review": "^4.3.3",
    "react-native-linear-gradient": "^2.6.2",
    "react-native-mixpanel": "^1.2.5",
    "react-native-pager-view": "^6.1.3",
    "react-native-pdf-thumbnail": "^1.2.1",
    "react-native-photo-manipulator": "^1.2.7",
    "react-native-render-html": "^6.3.4",
    "react-native-safe-area-context": "^4.4.0",
    "react-native-screens": "^3.20.0",
    "react-native-select-contact": "^1.6.3",
    "react-native-share": "^8.0.1",
    "react-native-snackbar": "^2.4.0",
    "react-native-splash-screen": "^3.3.0",
    "react-native-svg": "^13.6.0",
    "react-native-swiper": "^1.6.0",
    "react-native-tab-view": "^3.3.4",
    "react-native-wait-navigation": "^0.2.2",
    "react-native-webview": "^12.0.2",
    "react-native-wheel-pick": "^1.2.0",
    "react-number-format": "^5.0.1",
    "react-redux": "^8.0.4",
    "redux": "^4.2.0",
    "rn-fetch-blob": "^0.12.0",
    "yup": "^0.32.11"
  },
  "overrides": {
    "react-native-qrcode-svg": {
      "react-native-svg": "$react-native-svg"
    }
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native-community/eslint-config": "^3.2.0",
    "@tsconfig/react-native": "^2.0.2",
    "@types/jest": "^29.2.1",
    "@types/moment-duration-format": "^2.2.3",
    "@types/react": "^18.0.24",
    "@types/react-test-renderer": "^18.0.0",
    "@typescript-eslint/eslint-plugin": "^5.29.0",
    "@typescript-eslint/parser": "^5.29.0",
    "babel-jest": "^29.2.1",
    "eslint": "^8.19.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "^0.73.7",
    "moment-duration-format": "^2.3.2",
    "react-test-renderer": "18.2.0",
    "typescript": "^4.8.4"
  },
  "jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  },
  "eslintConfig": {
    "root": true,
    "extends": "@react-native-community/eslint-config",
    "rules": {
      "prettier/prettier": 0,
      "object-curly-spacing": [
        "error",
        "always"
      ],
      "array-bracket-spacing": [
        "error",
        "always"
      ]
    }
  }
}

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.myapp.original" xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.BLUETOOTH"/>
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION " />
 <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
 <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" /> 
    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher"
      android:allowBackup="false"
     android:usesCleartextTraffic="true"
      android:theme="@style/AppTheme">
      <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
   	<meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
        <meta-data
          android:name = "com.google.firebase.messaging.default_notification_icon"
          android:resource="@mipmap/ic_notification"
          tools:replace="android:resource"
        />
        <meta-data 
          android:name = "com.google.firebase.messaging.default_notification_color"
          android:resource="@color/myapp_color"
          tools:replace="android:resource" 
        />
      <provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="${applicationId}.provider"
        android:grantUriPermissions="true"
        android:exported="false">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/filepaths" />
    </provider>
    
    <activity android:name="com.facebook.FacebookActivity"
        android:configChanges=
                "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name" />
    <activity
        android:name="com.facebook.CustomTabActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="@string/fb_login_protocol_scheme" />
        </intent-filter>
    </activity>

      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
        android:launchMode="singleTask"
      android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data
        android:host="myapp.co.id"
        android:scheme="https"/>
</intent-filter>
      </activity>
    </application>

      <queries>
       <package android:name="com.myapp.staging" />
        <intent>
     <action android:name="android.intent.action.PICK" />
     <category android:name="android.intent.category.DEFAULT" />
     <data android:mimeType="vnd.android.cursor.dir/contact" />
</intent>
    </queries>
</manifest>

@szymonrybczak
Copy link
Collaborator

szymonrybczak commented Jul 20, 2023

You shouldn't have react-native-cli in your in package.json from latest few version the React Native CLI comes with React Native, so there's no need for installing it as separate package. Please remove and check if it is working for you.

Edit: also you shouldn't have npm as separate, and

    "@react-native-community/cli": "^10.1.3",
    "@react-native-community/cli-platform-android": "^10.0.0",

@cortinico
Copy link
Member

You shouldn't have react-native-cli in your in package.json

@szymonrybczak something to add to #1983 ?

@szymonrybczak
Copy link
Collaborator

@szymonrybczak something to add to #1983 ?

Good idea!

@jeroenvanhattem
Copy link

For me it was caused by react-native-image-picker. Updating it fixed it

@zhukai1204
Copy link

1.rm -fr node_modules
2.yarn install
3.yarn react-native run-android

@nhokmoon
Copy link

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.

Could not find method exec() for arguments [ReactNativeModules$_getCommandOutput_closure16@2eaa5049] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated.

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

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.

Could not find method exec() for arguments [ReactNativeModules$_getCommandOutput_closure16@2eaa5049] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated.

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

BUILD FAILED in 2s

at makeError (C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules\.pnpm\[email protected]\node_modules\execa\index.js:174:9)       
at C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules\.pnpm\[email protected]\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules\.pnpm\@[email protected]\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules\.pnpm\@[email protected]_@[email protected][email protected]\node_modules\@react-native-community\cli\build\index.js:192:9)

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.

Could not find method exec() for arguments [ReactNativeModules$_getCommandOutput_closure16@f6e6863] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated.

  • 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

@szymonrybczak
Copy link
Collaborator

hey @nhokmoon, make sure that npx react-native config works correctly and returns proper config of your app.

@iamblackdev
Copy link

@nhokmoon , did you fix the issue? i've been stuck for days now.

@liamjones
Copy link
Contributor

@nhokmoon

C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules\.pnpm\[email protected]\node_modules\execa\index.js:174:9

Does RN work with PNPM nowadays? It didn't use to.

@yashb-02
Copy link

yashb-02 commented Apr 25, 2024

Hello!
For me, it was because of the missing package attribute in AndroidManifest.xml in the module react-native-image-resizer

In node_modules/@bam_tech/react-native-image-resizer/android/src/main/AndroidManifest.xml

- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.reactnativeimageresizer">

And the value of package will the same as the value of namespace in node_modules/@bam_tech/react-native-image-resizer/android/build.gradle

I know that making changes directly in the node_modules is not good, so I will probably create a patch file for it.

Related to the node module:

Even though I raised a PR #399, I don't think that it is going to change in the module, since it was a change introduced in React Native 0.73 (react-native-community/discussions-and-proposals/issues/671)
Maybe in the near future this will be applied in other node modules too? I don't know because the discussion I linked dates back to Jun 17, 2023

@JJSLIoT
Copy link

JJSLIoT commented Apr 30, 2024

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 resolutions to my package.json to force use older RN CLI versions:

"resolutions": {
    "@react-native-community/cli": "^7.0.0",
    "@react-native-community/cli-config": "^7.0.0",
    "@react-native-community/cli-debugger-ui": "^7.0.0",
    "@react-native-community/cli-doctor": "^7.0.0",
    "@react-native-community/cli-platform-android": "^7.0.0",
    "@react-native-community/cli-platform-ios": "^7.0.0",
    "@react-native-community/cli-server-api": "^7.0.0",
    "@react-native-community/cli-tools": "^7.0.0",
    "@react-native-community/cli-types": "^7.0.0"
  }

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

@nhokmoon
Copy link

nhokmoon commented May 6, 2024

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 resolutions to my package.json to force use older RN CLI versions:

"resolutions": {
    "@react-native-community/cli": "^7.0.0",
    "@react-native-community/cli-config": "^7.0.0",
    "@react-native-community/cli-debugger-ui": "^7.0.0",
    "@react-native-community/cli-doctor": "^7.0.0",
    "@react-native-community/cli-platform-android": "^7.0.0",
    "@react-native-community/cli-platform-ios": "^7.0.0",
    "@react-native-community/cli-server-api": "^7.0.0",
    "@react-native-community/cli-tools": "^7.0.0",
    "@react-native-community/cli-types": "^7.0.0"
  }

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

thanks i will try it

@muhammadalizkhan
Copy link

tream

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.

@VBarzionov
Copy link

VBarzionov commented May 20, 2024

Hello, get same exception after upgrde to new version (0.74) of RN.

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

Could not find method exec() for arguments [ReactNativeModules$_getCommandOutput_closure16@f6e6863] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated.

BUILD FAILED in 5s how to fix this i'm stuck for 2 day

In my case the problem was an old android\gradlew.bat
It was created with previos RN version.

I copied gradlew.bat from blank project, and this issue moved away.

You may create reference project from last RN with command
npx @react-native-community/cli@latest init TestProject

P.S.
There are a lot other diffirences in *.gradle files comes with new version of RN.

@lnaidu14
Copy link

lnaidu14 commented Jun 2, 2024

OS: Windows 10
Java 17
Gradle 7.3

Hey guys,

This might not be the place to write this, but this is the issue that was closest to the problem I was facing. I am currently trying to integrate react-native-auth0 to my Expo project.

My current dependencies are:

"dependencies": { "@expo/vector-icons": "^14.0.0", "@react-navigation/native": "^6.0.2", "expo": "~51.0.9", "expo-camera": "~15.0.10", "expo-constants": "~16.0.2", "expo-font": "~12.0.5", "expo-linking": "~6.3.1", "expo-modules-autolinking": "^1.11.1", "expo-router": "~3.5.14", "expo-splash-screen": "~0.27.4", "expo-status-bar": "~1.12.1", "expo-system-ui": "~3.0.4", "expo-web-browser": "~13.0.3", "react": "18.2.0", "react-dom": "18.2.0", "react-hook-form": "^7.51.5", "react-native": "0.74.1", "react-native-auth0": "^3.2.1", "react-native-floating-action": "^1.22.0", "react-native-gesture-handler": "~2.16.1", "react-native-reanimated": "~3.10.1", "react-native-safe-area-context": "4.10.1", "react-native-screens": "3.31.1", "react-native-web": "~0.19.10" }, "devDependencies": { "@babel/core": "^7.20.0", "@types/jest": "^29.5.12", "@types/react": "~18.2.45", "@types/react-test-renderer": "^18.0.7", "jest": "^29.2.1", "jest-expo": "~51.0.2", "react-test-renderer": "18.2.0", "typescript": "~5.3.3" },

I'm running Java 17 and Gradle 7.3 (which is what I need to use according to the compatibility matrix. The Auth0 library only runs with native code. So when trying to build the Android native code using the Expo builder, i.e. npx expo run:android, I keep getting this error:

`npx expo run:android
env: load .env
env: export EXPO_PUBLIC_AUTH0_DOMAIN EXPO_PUBLIC_AUTH0_CLIENT_ID
› Building app...
Picked up _JAVA_OPTIONS: -Xmx512M
Configuration on demand is an incubating feature.

FAILURE: Build failed with an exception.

  • Where:
    Script '\node_modules\expo\scripts\autolinking.gradle' line: 4

  • What went wrong:
    A problem occurred evaluating script.

Could not find method exec() for arguments [autolinking_7wnwhgbtt7rc3qqznqll89fti$_run_closure1@46e55161] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated.

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

BUILD FAILED in 969ms
Error: \android\gradlew.bat app:assembleDebug -x lint -x test --configure-on-demand --build-cache -PreactNativeDevServerPort=8081 -PreactNativeArchitectures=x86_64,arm64-v8a exited with non-zero code: 1
Error: \android\gradlew.bat app:assembleDebug -x lint -x test --configure-on-demand --build-cache -PreactNativeDevServerPort=8081 -PreactNativeArchitectures=x86_64,arm64-v8a exited with non-zero code: 1
at ChildProcess.completionListener (\node_modules@expo\spawn-async\build\spawnAsync.js:42:23)
at Object.onceWrapper (node:events:629:26)
at ChildProcess.emit (node:events:514:28)
at cp.emit (\node_modules\cross-spawn\lib\enoent.js:34:29)
at maybeClose (node:internal/child_process:1091:16)
at ChildProcess._handle.onexit (node:internal/child_process:302:5)
...
at spawnAsync (\node_modules@expo\spawn-async\build\spawnAsync.js:7:23)
at spawnGradleAsync (\node_modules@expo\cli\build\src\start\platforms\android\gradle.js:96:48)
at assembleAsync (\node_modules@expo\cli\build\src\start\platforms\android\gradle.js:74:18)
at runAndroidAsync (\node_modules@expo\cli\build\src\run\android\runAndroidAsync.js:45:37)`

I get the same result when changing directory (cd) to the android folder and running gradle build.

This is the code in my expo\scripts\autolinking.gradle:

// Resolve expo>expo-modules-autolinkingdependency chain def autolinkingPath = ["node", "--print", "require.resolve('expo-modules-autolinking/package.json', { paths: [require.resolve('expo/package.json')] })"] apply from: new File( providers.exec { workingDir(rootDir) commandLine(autolinkingPath) }.standardOutput.asText.get().trim(), "../scripts/android/autolinking_implementation.gradle" )

Any help would be appreciated. Please let me know if any other information is needed. For more context, this is the repository and branch I am working on https://github.com/lnaidu14/quickpay/tree/19-integrate-auth0

@arthedza
Copy link

arthedza commented Jun 20, 2024

The problem is that the package attribute is initially present in the camera-roll manifest file, but for some reason it is removed from it after running Gradle. That's why this error disappears after removing node_modules but occurs again after running a build once again. Perhaps Gradle merges manifest files somehow incorrectly. If you remove the package attribute from the manifest file of your application (android/app/src/main/AndroidManifest.xml), you will not get this error (although then you will get another error saying that the package attribute must be present in the manifest file of your application). In the node_modules/@react-native-camera-roll/camera-roll/android/build.gradle file there's a property of namespace however, it is used conditionally. Maybe it should always be included?
image

UPD. I just changed the line def shouldUseNameSpace = agpVersion >= 7 to def shouldUseNameSpace = false and created a patch using patch-package and the issue was resolved for me.

@captainalbert
Copy link

After discussing this issue with @cortinico, the problem is with broken backward compatibility in libraries, right now for this we have two solutions:

  1. Use React Native 0.71 or 0.72,
  2. Downgrade libraries to the version that contains package field in AndroidManfiest.xml

We'll upstream fixes for this to the older versions (0.69, 0.70) of RN soon.

Hi, were you able to upstream the fix for .69?

@ayi12138
Copy link

我也有这个问题,想问下怎么解决的

@christophby
Copy link

@captainalbert did you find a solution for .69?

@captainalbert
Copy link

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

@Gabrielfrahm
Copy link

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

@duyrk
Copy link

duyrk commented Sep 27, 2024

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

@Riazalmahmud
Copy link

Riazalmahmud commented Sep 29, 2024

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

@paramveer665
Copy link

Having same problem on 0.74.5

@minikdev
Copy link

minikdev commented Oct 8, 2024

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?

@7adidaz
Copy link

7adidaz commented Oct 14, 2024

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


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests