Repository navigation
Closed
Labels
Description
After recent update in cli-platform-android the project doesn't start. Stating Cannot invoke method getErrorStream() on null object. I wanted to submit an issue for that package but I could not find a github repo for that.
$ react-native run-android
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...
info Installing the app...
:ReactNative:Cannot run program "npx": CreateProcess error=2, ═х єфрхЄё эрщЄш єърчрээ√щ Їрщы
:ReactNative:Automatic import of native modules failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\TEMP\natapp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 169
* What went wrong:
A problem occurred evaluating script.
> Cannot invoke method getErrorStream() on null object
* 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 1s
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 --v
erbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* Where:
Script 'C:\TEMP\natapp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 169
* What went wrong:
A problem occurred evaluating script.
> Cannot invoke method getErrorStream() on null object
* 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 1s
at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (C:\TEMP\natapp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at buildAndRun (C:\TEMP\natapp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
at C:\TEMP\natapp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
at processTicksAndRejections (internal/process/task_queues.js:85:5)
at async Command.handleAction (C:\TEMP\natapp\node_modules\@react-native-community\cli\build\index.js:164:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I'm running on Windows 10 x64 and node version is 12.8.0
Reacted by ImranNZ, 鏡月, Abhishek Prashant, Amit Sengupta, Pratik Bhattacharya, Pratik Golchha, Balasubramanian Chandran, KRohitJ, Sapan Kumar Das, monarathour and 9 more
Activity
thymikee commentedon Oct 15, 2019
thymikee commentedon Oct 15, 2019
I see
Cannot run program "npx"in the error message. Can you verifynpxworks for you as a standalone command? It should ship with npm by default.mkinfrared commentedon Oct 15, 2019
Yes it does. I created the project using this command
npx react-native init MyApp --template react-native-template-typescriptAnd I noticed that platform-android was updated recently. Before this update everything worked fine.
thymikee commentedon Oct 15, 2019
Ww change quite a bit there to improve monorepo support. We would appreciate further debugging on this
mkinfrared commentedon Oct 15, 2019
thymikee commentedon Oct 15, 2019
franzon commentedon Oct 15, 2019
erickriva commentedon Oct 16, 2019
I had started a project with npx react-native, but react-native was installed globally, I uninstalled it and everything is working fine now
gauravagerwala commentedon Oct 16, 2019
deepanjandas commentedon Oct 16, 2019
zrelyydereva commentedon Oct 16, 2019
I'm on same status
Node Version: v12.12.0
react-native --version
3.3.0-alpha.6
On Windows, npx command is "npx.cmd" and windows terminal can omit extensions for executables(i.e. bat,cmd,exe ) .so we can run npx by "npx" in the terminal, but it's looks only in terminal (except for *.exe)
I modified native_modules.gradle L.153 "npx --quiet react-native config" to "npx.cmd --quiet react-native config" ,then I could run run-android
but it's not smart and not portable.
30 remaining items
david-laurentino commentedon Nov 2, 2019
The problem here is that $PATH variable isn't inherited through getRuntime().exec. I do not know exactly why, but seams to be related to the NVM.
Vednus commentedon Nov 22, 2019
I was running into this error:
Unexpected empty result of running 'npx --quiet --no-install react-native config' command from 'null' directory.when building in appcenter (it built fine locally) and ended up having to downgradecli-platform-androidto^2.9.0based on this comment: react/react-native#26929 (comment) In order to get it to work. I'm dealing with a monorepo and think it was a pathing issue, although it built fine in appcenter for iOS.brianinator commentedon Nov 26, 2019
I had same issue as @Vednus. I ended up adding the react-native-cli versions as resolutions in the package.json as described above.
talatatac commentedon Nov 29, 2019
it's working. ty
shaoyinyi commentedon Nov 29, 2019
it seems we have the same problems ,by the way , my version : react-native-cli: 2.0.1
react-native: 0.61.5
david-laurentino commentedon Nov 29, 2019
Maybe the $PATH variable isn't inherited through Java Runtime correctly. The $PATH inherited is one statitically defined. If you use NVM that defines $PATH dinamically including node according version, it is not propagated to Java Runtime which is where commands are executed. Install npx globally solve the problem once It put the npx in $PATH statically. Here despite having NVM I put the node on $PATH statically, but theses solutions seems workaround.
jgreen210 commentedon Dec 18, 2019
Installing node/npx globally is not a good fix. E.g. test servers testing many branches/projects shouldn't rely on a shared node/npx version - different branches/projects will in general need different versions.
To support nodenv/nvm etc., npx (and node etc.) should be taken from the PATH.
macOS apps with a UI, e.g. Android Studio and the Terminal sometimes used to start the packager/bundler, generally don't have env. vars. set unfortunately.
fix: temporary fix for a regression in monorepos (#852)
thymikee commentedon Dec 18, 2019
Looks like
npxcauses more issues than we anticipated. We'll need to use a different approach and once that's done, we'll as for feedback and more thorough testingjasoncool commentedon Dec 19, 2019
Caused by: java.io.IOException: Cannot run program "npx.cmd": CreateProcess error=2, 系统找不到指定的文件。
at java_lang_Runtime$exec$0.call(Unknown Source)
at ReactNativeModules.getCommandOutput(F:\RNProject\AwesomeProject\node_modules@react-native-community\cli-platform-android\native_modules.gradle:154)
at ReactNativeModules.getCommandOutput(F:\RNProject\AwesomeProject\node_modules@react-native-community\cli-platform-android\native_modules.gradle)
at ReactNativeModules.getReactNativeConfig(F:\RNProject\AwesomeProject\node_modules@react-native-community\cli-platform-android\native_modules.gradle:194)
at ReactNativeModules$getReactNativeConfig.callCurrent(Unknown Source)
at ReactNativeModules.(F:\RNProject\AwesomeProject\node_modules@react-native-community\cli-platform-android\native_modules.gradle:84)
at native_modules_d6l6y8msnqttbqz64d6riqzsh.run(F:\RNProject\AwesomeProject\node_modules@react-native-community\cli-platform-android\native_modules.gradle:238
)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
... 147 more
Caused by: java.io.IOException: CreateProcess error=2, 系统找不到指定的文件。
... 155 more
Bartmr commentedon Dec 20, 2019
NVM sets up it's environment variables in the
.bashrcfile, which only sets the environment variables for Bash. These seem to not be accessible to terminal commands ran from Gradle. The solution is to move the NVM specific code from the.bashrcfile in the home directory to the.profilefile, also in the home directory. This NVM specific code looks like this:Restart your computer after, and try to open Android Studio again.
asherccohen commentedon Jan 5, 2020
Same exact problem here. Running npx command in a monorepo and the directory is null.
First I get:
:ReactNative:Unexpected empty result of running 'npx.cmd --quiet --no-install react-native config' command from 'null' directory.
:ReactNative:Running 'npx.cmd --quiet --no-install react-native config' command from 'null' directory failed
Then , decommenting the dir argument at line 194of native_modules.gradle the error disappears but still crashed during build:
What went wrong:
A problem occurred evaluating script.
React Native CLI failed to determine Android project configuration. This is likely due to misconfiguration. Config output:
asherccohen commentedon Jan 5, 2020
UPDATE: I downgraded react-native to 0.60.0 and was able to see the build progress. Unfortunately when it got to Task :app:processDebugResources it FAILED.
FDiskas commentedon Feb 3, 2020
In my case
npxwas not found I think that this is because I installed node usingNVMcabelin commentedon Apr 6, 2020
In my case through the terminal I was able to compile and run it, I just couldn't sync through Android Studio.
I use linux and my Android Studio was installed via flatpak.
I performed the manual installation of Android Studio and gradlew got access to npx