System:
OS: macOS Mojave 10.14.4
CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Memory: 1.20 GB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.10.2 - ~/.nvm/versions/node/v10.13.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
Android SDK:
API Levels: 26, 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-29 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5900203
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
Andrei ~ desktop ReactConf native_navigation ✚ 1 … 1 yarn list @react-native-community/cli
yarn list v1.12.3
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ @react-native-community/[email protected]
✨ Done in 0.57s.
I'm able to build and run on device using npx react-native run-android, however, when I open Android Studio I'm unable to sync gradle.
Clean init with npx react-native init FreshApp
Caused by: org.gradle.internal.exceptions.LocationAwareException: Script '/Users/Andrei/desktop/ReactConf/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 191
A problem occurred evaluating settings 'ReactConf'.
Full log file from Gradle failure:
I noticed some other issues related to this, I tried to going over them and to find a fix, but I failed so far. Most seem related to a Monorepo structure, which is not my case.
Any clues how I can fix this?
Thanks for the report. Can you show me your project structure (where you have package.json(s), Android and iOS code)? Are you using a monorepo?
Please update to latest alpha and try once again. We have recently shipped a fix (two days ago or something) and closed the issues.
Hello
There is an issue with @react-native-community/cli-platform-android/native_modules.gradle in 3.0.0-alpha7
Under OSX, java do not inherit environment variables and you run command using simple cmdProcess = Runtime.getRuntime().exec(command).
Regards Gradle code (getReactNativeConfig method)
Runtime.getRuntime().exec(command) do not throw exception if invoked command return 0 and just report about problem to the error output. As result you get empty reactNativeConfigOutput.
To fix it you should
if(reactNativeConfigOutput == null || reactNativeConfigOutput.length() == 0) {
throw new RuntimeException("Empty output of " + command);
}
Then I correctly throw exception I get warning from npx
:ReactNative:Empty output of npx --quiet react-native config
:ReactNative:Automatic import of native modules failed.
:ReactNative:Command `config` unrecognized. Make sure that you have run `npm install` and that you are inside a react-native project.
It means you run npx in the incorrect directory.
I did not get how to get top dir in this code (gradle is messed up tool built entirely to charge customers more to fix issues made by gradle itself), so I hardcoded it for my case.
def jenv = new String[0]
cmdProcess = Runtime.getRuntime().exec(command, jenv, new File("path to my project"))
This time I get another error because PATH is not inherited (pay attention to node)
:ReactNative:Empty output of npx --quiet react-native config
:ReactNative:Automatic import of native modules failed.
:ReactNative:env: node: No such file or directory
ok, lets pass proper path to exec
def jenv = new String[1]
jenv[0] = "PATH=<my path hardcoded>"
cmdProcess = Runtime.getRuntime().exec(command, jenv, new File("My project dir with package.json"))
Bingo! build is ok. Unfortunately, I have no time to provide community with complete fix, but hope it will help.
System:
OS: macOS High Sierra 10.13.6
CPU: (4) x64 Intel(R) Core(TM) i7 CPU M 620 @ 2.67GHz
Memory: 106.28 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.6.0 - /usr/local/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.7.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
IDEs:
Android Studio: 3.1 AI-173.4720617
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
npmGlobalPackages:
react-native-cli: 2.0.1
Gradle MUST DIE!
@ifyapishore It's likely that you have react-native or react-native-cli installed globally, please remove them. Also, if that doesn't help, please share your project structure. We expect node_modules/react-native to be accessible to Node resolution (so anywhere up the android/ directory).
Both installed locally. Please read my comment carefully. Code below will NEVER work properly under OSX. You need to pass PATH variable.
Runtime.getRuntime().exec(command)
You can test it with simple java app

I modified native_modules.gradle to fix the issue.

My project structure is something like this:
app
node_modules
android
...
scripts
fastlane
Fastfile
...
I run fastlane inscripts folder. Fastfile references android project in app folder.
Since upgrading RN from 0.60.5 to 0.61.2, I have been getting the same issue as @ifyapishore for Android only.
@superandrew213 are you able to set up a reproduction repo, that we could check out and see what's up?
Here is a repo:
https://github.com/AndreiCalazans/rn-cli-test
I don't have react-native installed globally, I'm using npx react-native.
I just built a project this morning with npx react-native init test, I uploaded this project to the repo I linked above.
I'm on the latest version of the cli.
Andrei ~ desktop test master npx react-native --version
3.0.0-alpha.7
No modification to the project structure was made.

@AndreiCalazans please see https://github.com/react-native-community/cli/issues/816#issuecomment-544492778 and let me know if it affects you.
@AndreiCalazans it runs fine for me.
@thymikee this fails for me for https://github.com/superandrew213/rn-cli-test-project.
@superandrew213 I'm running ./android/gradlew bundleRelease -p ./android/ from app folder and it works just fine (I've adjusted paths, because there's no need going outside of app/ dir)
Try running it inside scripts folder. That is where I run fastlane. I don't keep the fastlane code together with the app code.
This was working before the RN0.61.2 upgrade and still works for ios.
I have Env Variables set up. I had this all working on previous React Native versions, started happening after updating to latest CLI.



PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Users/Andrei/.nvm/versions/node/v12.13.0/bin:/Users/Andrei/Library/Android/sdk//emulator:/Users/Andrei/Library/Android/sdk//tools:/Users/Andrei/.fastlane/bin:~/Documents/flutter/bin:/Users/Andrei/Library/Python/2.7/bin:/Users/Andrei/Library/Android/sdk//tools/bin:/Users/Andrei/Library/Android/sdk//platform-tools
@superandrew213 it works for me too, I can build and run it on device with the CLI but not inside Android studio.
Here's a PR solving this issue: https://github.com/react-native-community/cli/pull/824. Please test in your environments.
@thymikee this PR works for me. Thank you! 👍
There seem to be a lot of issues on this regression. I'd suggest moving fast on this fix.
We found that downgrading the openjdk to 8 fixed this issue for us as a workaround.
Reopening because of https://github.com/react-native-community/cli/pull/852. We need to find better solution
I've solved like this on native_modules.gradle
`diff
- def command = "${npx} --quiet --no-install react-native config"
+ def command = "yarn --silent react-native config"
`
Does it still happening on latest RN with latest CLI? Instructions how to upgrade @react-native-community/cli to the latest version.
Going to close due to inactivity and the fact we think it's been closed. Let's reopen when happens again.
Most helpful comment
@thymikee this PR works for me. Thank you! 👍
There seem to be a lot of issues on this regression. I'd suggest moving fast on this fix.