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

run-android failed 'C:\Program' is not recognized as an internal or external command #26921

Closed
omidazm94 opened this issue Oct 19, 2019 · 16 comments
Labels
Bug Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@omidazm94
Copy link

omidazm94 commented Oct 19, 2019

hi, i'm facing this problem and its weird cause it happened when i created a new project with react-native init two days ago. i can run the old project but when i try to use command react-native run-android in the new project it gives me an error. and from the last few days every project that i build have a problem even if i build with Previous react-native versions, something comes like warnOnce and so on. is it something new that changed in react and react-native that cause these problems ?
please help me
#25936
(react-native info)
React Native version:
System:
OS: Windows 10
CPU: (8) x64 Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz
Memory: 4.21 GB / 7.95 GB
Binaries:
Node: 8.11.3 - C:\Program Files\nodejs\node.EXE
npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.5.0.0 AI-191.8026.42.35.5791312
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 863 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
info Launching emulator...
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
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...

FAILURE: Build failed with an exception.

Where:
Script 'C:\Users\omidazm\Desktop\web\learning\react-native\green26\node_modules@react-native-community\cli-platform-android\native_modules.gradle' line: 182

What went wrong:
A problem occurred evaluating script.

Unable to determine the current character, it is not a string, number, array, or object

The current character read is 'C' with an int value of 67
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
C:\Users\omidazm\Desktop\web\learning\react-native\green26\node_modules\react-native\cli.js{ "root": "C:\Users\omidazm\Desktop\web\learning\react-native\green26", "reactNativePath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\node_modules\react-native", "dependencies": {}, "commands": [ { "name": "log-ios", "description": "starts iOS device syslog tail" }, { "name": "run-ios", "description": "builds your app and starts it on iOS simulator", "examples": [ { "desc": "Run on a different simulator, e.g. iPhone 5", "cmd": "react-native run-ios --simulator "iPhone 5"" }, { "desc": "Pass a non-standard location of iOS directory", "cmd": "react-native run-ios --project-path "./app/ios"" }, { "desc": "Run on a connected device, e.g. Max's iPhone", "cmd": "react-native run-ios --device "Max's iPhone"" }, { "desc": "Run on the AppleTV simulator", "cmd": "react-native run-ios --simulator "Apple TV" --scheme "helloworld-tvOS"" } ], "options": [ { "name": "--simulator [string]", "description": "Explicitly set simulator to use. Optionally include iOS version betweenparenthesis at the end to match an exact version: "iPhone 6 (10.0)"", "default": "iPhone 11" }, { "name": "--configuration [string]", "description": "Explicitly set the scheme configuration to use", "default": "Debug" }, { "name": "--scheme [string]", "description": "Explicitly set Xcode scheme to use" }, { "name": "--project-path [string]", "description": "Path relative to project root where the Xcode project (.xcodeproj) lives.", "default": "ios" }, { "name": "--device [string]", "description": "Explicitly set device to use by name. The value is not required if you have a single device connected." }, { "name": "--udid [string]", "description": "Explicitly set device to use by udid" }, { "name": "--no-packager", "description": "Do not launch packager while building" }, { "name": "--verbose", "description": "Do not use xcpretty even if installed" }, { "name": "--port [number]", "default": 8081 }, { "name": "--terminal [string]", "description": "Launches the Metro Bundler in a new window using the specified terminal path." } ] }, { "name": "log-android", "description": "starts logkitty" }, { "name": "run-android", "description": "builds your app and starts it on a connected Android emulator or device", "options": [ { "name": "--root [string]", "description": "Override the root directory for the android build (which contains the android directory)", "default": "" }, { "name": "--variant [string]", "description": "Specify your app's build variant", "default": "debug" }, { "name": "--appFolder [string]", "description": "Specify a different application folder name for the android source. If not, we assume is "app"", "default": "app" }, { "name": "--appId [string]", "description": "Specify an applicationId to launch after build.", "default": "" }, { "name": "--appIdSuffix [string]", "description": "Specify an applicationIdSuffix to launch after build.", "default": "" }, { "name": "--main-activity [string]", "description": "Name of the activity to start", "default": "MainActivity" }, { "name": "--deviceId [string]", "description": "builds your app and starts it on a specific device/simulator with the given device id (listed by running "adb devices" on the command line)." }, { "name": "--no-packager", "description": "Do not launch packager while building" }, { "name": "--port [number]", "default": 8081 }, { "name": "--terminal [string]", "description": "Launches the Metro Bundler in a new window using the specified terminal path." }, { "name": "--tasks [list]", "description": "Run custom Gradle tasks. By default it's "installDebug"" }, { "name": "--no-jetifier", "description": "Do not run "jetifier" – the AndroidX transition tool. By default it runs before Gradle to ease working with libraries that don't support AndroidX yet. See more at: https://www.npmjs.com/package/jetifier.", "default": false } ] } ], "assets": [], "platforms": { "ios": {}, "android": {} }, "haste": { "providesModuleNodeModules": [ "react-native" ], "platforms": [ "ios", "android" ] }, "project": { "ios": { "sourceDir": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\ios", "folder": "C:\Users\omidazm\Desktop\web\learning\react-native\green26", "pbxprojPath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\ios\green26.xcodeproj\project.pbxproj", "podfile": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\ios\Podfile", "podspecPath": null, "projectPath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\ios\green26.xcodeproj", "projectName": "green26.xcodeproj", "libraryFolder": "Libraries", "sharedLibraries": [], "plist": [], "scriptPhases": [] }, "android": { "sourceDir": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\app", "isFlat": false, "folder": "C:\Users\omidazm\Desktop\web\learning\react-native\green26", "stringsPath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\app\src\main\res\values\strings.xml", "manifestPath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\app\src\main\AndroidManifest.xml", "buildGradlePath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\app\build.gradle", "settingsGradlePath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\settings.gradle", "assetsPath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\app\src\main\assets", "mainFilePath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\app\src\main\java\com\green26\MainApplication.java", "packageName": "com.green26" } }}
^

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 23s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

Where:
Script 'C:\Users\omidazm\Desktop\web\learning\react-native\green26\node_modules@react-native-community\cli-platform-android\native_modules.gradle' line: 182

What went wrong:
A problem occurred evaluating script.

Unable to determine the current character, it is not a string, number, array, or object

The current character read is 'C' with an int value of 67
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
C:\Users\omidazm\Desktop\web\learning\react-native\green26\node_modules\react-native\cli.js{ "root": "C:\Users\omidazm\Desktop\web\learning\react-native\green26", "reactNativePath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\node_modules\react-native", "dependencies": {}, "commands": [ { "name": "log-ios", "description": "starts iOS device syslog tail" }, { "name": "run-ios", "description": "builds your app and starts it on iOS simulator", "examples": [ { "desc": "Run on a different simulator, e.g. iPhone 5", "cmd": "react-native run-ios --simulator "iPhone 5"" }, { "desc": "Pass a non-standard location of iOS directory", "cmd": "react-native run-ios --project-path "./app/ios"" }, { "desc": "Run on a connected device, e.g. Max's iPhone", "cmd": "react-native run-ios --device "Max's iPhone"" }, { "desc": "Run on the AppleTV simulator", "cmd": "react-native run-ios --simulator "Apple TV" --scheme "helloworld-tvOS"" } ], "options": [ { "name": "--simulator [string]", "description": "Explicitly set simulator to use. Optionally include iOS version betweenparenthesis at the end to match an exact version: "iPhone 6 (10.0)"", "default": "iPhone 11" }, { "name": "--configuration [string]", "description": "Explicitly set the scheme configuration to use", "default": "Debug" }, { "name": "--scheme [string]", "description": "Explicitly set Xcode scheme to use" }, { "name": "--project-path [string]", "description": "Path relative to project root where the Xcode project (.xcodeproj) lives.", "default": "ios" }, { "name": "--device [string]", "description": "Explicitly set device to use by name. The value is not required if you have a single device connected." }, { "name": "--udid [string]", "description": "Explicitly set device to use by udid" }, { "name": "--no-packager", "description": "Do not launch packager while building" }, { "name": "--verbose", "description": "Do not use xcpretty even if installed" }, { "name": "--port [number]", "default": 8081 }, { "name": "--terminal [string]", "description": "Launches the Metro Bundler in a new window using the specified terminal path." } ] }, { "name": "log-android", "description": "starts logkitty" }, { "name": "run-android", "description": "builds your app and starts it on a connected Android emulator or device", "options": [ { "name": "--root [string]", "description": "Override the root directory for the android build (which contains the android directory)", "default": "" }, { "name": "--variant [string]", "description": "Specify your app's build variant", "default": "debug" }, { "name": "--appFolder [string]", "description": "Specify a different application folder name for the android source. If not, we assume is "app"", "default": "app" }, { "name": "--appId [string]", "description": "Specify an applicationId to launch after build.", "default": "" }, { "name": "--appIdSuffix [string]", "description": "Specify an applicationIdSuffix to launch after build.", "default": "" }, { "name": "--main-activity [string]", "description": "Name of the activity to start", "default": "MainActivity" }, { "name": "--deviceId [string]", "description": "builds your app and starts it on a specific device/simulator with the given device id (listed by running "adb devices" on the command line)." }, { "name": "--no-packager", "description": "Do not launch packager while building" }, { "name": "--port [number]", "default": 8081 }, { "name": "--terminal [string]", "description": "Launches the Metro Bundler in a new window using the specified terminal path." }, { "name": "--tasks [list]", "description": "Run custom Gradle tasks. By default it's "installDebug"" }, { "name": "--no-jetifier", "description": "Do not run "jetifier" – the AndroidX transition tool. By default it runs before Gradle to ease working with libraries that don't support AndroidX yet. See more at: https://www.npmjs.com/package/jetifier.", "default": false } ] } ], "assets": [], "platforms": { "ios": {}, "android": {} }, "haste": { "providesModuleNodeModules": [ "react-native" ], "platforms": [ "ios", "android" ] }, "project": { "ios": { "sourceDir": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\ios", "folder": "C:\Users\omidazm\Desktop\web\learning\react-native\green26", "pbxprojPath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\ios\green26.xcodeproj\project.pbxproj", "podfile": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\ios\Podfile", "podspecPath": null, "projectPath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\ios\green26.xcodeproj", "projectName": "green26.xcodeproj", "libraryFolder": "Libraries", "sharedLibraries": [], "plist": [], "scriptPhases": [] }, "android": { "sourceDir": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\app", "isFlat": false, "folder": "C:\Users\omidazm\Desktop\web\learning\react-native\green26", "stringsPath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\app\src\main\res\values\strings.xml", "manifestPath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\app\src\main\AndroidManifest.xml", "buildGradlePath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\app\build.gradle", "settingsGradlePath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\settings.gradle", "assetsPath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\app\src\main\assets", "mainFilePath": "C:\Users\omidazm\Desktop\web\learning\react-native\green26\android\app\src\main\java\com\green26\MainApplication.java", "packageName": "com.green26" } }}
^

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 23s

at checkExecSyncError (child_process.js:601:13)
at execFileSync (child_process.js:621:13)
at runOnAllDevices (C:\Users\omidazm\Desktop\web\learning\react-native\green26\node_modules@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at
at process._tickCallback (internal/process/next_tick.js:188:7)

Steps To Reproduce

1.react-native init project_name
2.react-native run-android

@omidazm94 omidazm94 added the Bug label Oct 19, 2019
@react-native-bot react-native-bot added the Platform: Android Android applications. label Oct 19, 2019
@react-native-bot
Copy link
Collaborator

Thanks for submitting your issue. Can you take another look at your description and make sure the issue template has been filled in its entirety?

👉 Click here if you want to take another look at the Bug Report issue template.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Resolution: Needs More Information labels Oct 19, 2019
@react-native-bot
Copy link
Collaborator

Can you run react-native info and edit your issue to include these results under the React Native version: section?

If you believe this information is irrelevant to the reported issue, you may write `[skip envinfo]` alongside an explanation in your Environment: section.

@EnduIf
Copy link

EnduIf commented Oct 20, 2019

After some testing i was able to reproduce the Issue. The problem is your Node version is outdated. The requirement for React-Native is version 8.3 or newer. If you Update everything should be fine. But be careful because of this #26598 issue. The LTS version 10.16.3 should work fine.

@HessiPard
Copy link

After some testing i was able to reproduce the Issue. The problem is your Node version is outdated. The requirement for React-Native is version 8.3 or newer. If you Update everything should be fine. But be careful because of this #26598 issue. The LTS version 10.16.3 should work fine.

I had this problem and updating node to v12.13.0 LTS solved error.

@HessiPard
Copy link

HessiPard commented Oct 21, 2019

After some testing i was able to reproduce the Issue. The problem is your Node version is outdated. The requirement for React-Native is version 8.3 or newer. If you Update everything should be fine. But be careful because of this #26598 issue. The LTS version 10.16.3 should work fine.

I had this problem and updating node to v12.13.0 LTS solved error.

As @NyauIf mentioned, v12.13.0 LTS causes this error#26598.
Latest working version of node is v12.10.0

@omidazm94
Copy link
Author

omidazm94 commented Oct 22, 2019

thank you for your answers. problem was nodejs and i tried to update node and i get "can't read property 'resolve'" error. so i used this page and fixed it.
https://stackoverflow.com/questions/50597159/npm-err-asyncwrite-is-not-a-function/53985680#53985680
(Solution for windows platform
Uninstall Node
Delete folder from programfiles if exist (C:\Program Files\nodejs)
Delete npm's data folder: C:\Users{Your uername}\AppData\Roaming\nmp
Install node Again(use different installation folder like "C:\Program Files\nodejs-2")
Root cause is node and nvm installed in same installation folder.)
now i can use react-native latest version :-))

@shahbazhaider
Copy link

shahbazhaider commented Oct 25, 2019

React Native Sucks

I am unable to ran even a simple project
Worst Technology i have ever used..
Getting same error .

please help ,

Error........................

info Running jetifier to migrate libraries to AndroidX. You can
disable it using "--no-jetifier" flag.
Jetifier found 863 file(s) to forward-jetify. Using 4 workers...info JS server already running.
'C:\Users\Shahbaz' is not recognized as an internal or external
command,
operable program or batch file.
info Launching emulator...
'C:\Users\Shahbaz' is not recognized as an internal or external
command,
operable program or batch file.
'C:\Users\Shahbaz' is not recognized as an internal or external
command,
operable program or batch file.
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...
The system cannot find the path specified.
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
The system cannot find the path specified.
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (E:\study & work\Work Space\React Native Work\Test\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at process._tickCallback (internal/process/next_tick.js:68:7)

@EnduIf
Copy link

EnduIf commented Oct 26, 2019

Hi @shahbazhaider, yes your problem looks similar. Older NodeJs versions apparently have Problems with spaces in the path. Are you able to provide your NodeJs version with node -v ? You should have a version newer then NodeJs v8.3. The NodeJs v10.15.2 should work fine. But be Careful with your version because of this #26598 issue. If the Problem also occurs on the NodeJs v10.15.2 feel free to text me.

@saravanaams
Copy link

Hi Team,
I have updated my node to 10.17.0. Still i'm facing the error.

npx react-native info

System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Memory: 7.89 GB / 15.91 GB
Binaries:
Node: 10.17.0 - C:\Program Files\nodejs\node.EXE
npm: 6.11.3 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.5.0.0 AI-191.8026.42.35.5977832
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.4 => 0.61.4

Error

react-native-run-error

@satyadaraviteja
Copy link

heloo bro same problem facing ...space in folder path

@fabOnReact
Copy link
Contributor

please close this, this has nothing to do with react native

You did not follow the instructions at https://reactnative.dev/docs/environment-setup and did not install correct node version

Even if you did follow correct instructions, you stll had to open the issue in nodejs repository and not facebook/react-native

@Rbayat75
Copy link

Untitled
I have a error
please help me

info Starting JS server...
The system cannot find the path specified.
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of emulator -list-avds.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Downloading https://services.gradle.org/distributions/gradle-6.2-all.zip

Exception in thread "main" java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 403 Request blocked by Privoxy"
at sun.net.www.protocol.http.HttpURLConnection.doTunneling(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at org.gradle.wrapper.Download.downloadInternal(Download.java:78)
at org.gradle.wrapper.Download.download(Download.java:63)
at org.gradle.wrapper.Install$1.call(Install.java:68)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Exception in thread "main" java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 403 Request blocked by Privoxy"

@AlphaJuliettOmega
Copy link

This is not fixable by using a specific Node Version, I'm going to try move my Node install to a path without a space.

$ node -v
v14.15.0

@AlphaJuliettOmega
Copy link

Yeah, that did it, thank you @omidazm94

@udaraliyanage96cs
Copy link

hy i have same issue.. how did you fix it

@esteves-esta
Copy link

On my case it was the space on the path name in the config file of node/npm.

  1. I used the command npm config get prefix to check if the path had an space in it
  2. Used the command cmd /c dir /x on the parent folder to get the short name of the folder that I wanted, on my case i used it on the "C:\Users" folder to get my user folder name.
  3. Used the command npm config set prefix "C:\Users\{SHORT FOLDER NAME}"

@facebook facebook locked as resolved and limited conversation to collaborators Oct 3, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests