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

"Text must not be null or empty" error occurs on Android Studio. #468

Closed
ryohlan opened this issue Jul 4, 2019 · 9 comments
Closed

"Text must not be null or empty" error occurs on Android Studio. #468

ryohlan opened this issue Jul 4, 2019 · 9 comments
Labels
bug Something isn't working

Comments

@ryohlan
Copy link

ryohlan commented Jul 4, 2019

Environment

System:
OS: macOS 10.14.5
CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
Memory: 168.03 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
Yarn: 1.2.1 - /usr/local/bin/yarn
npm: 6.8.0 - ~/.nvm/versions/node/v10.13.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 21, 22, 23, 24, 25, 26, 27, 28
Build Tools: 22.0.1, 23.0.1, 23.0.2, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.3, 27.0.3, 28.0.2, 28.0.3
System Images: android-24 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.0 => 0.60.0
npmGlobalPackages:
create-react-native-module: 0.5.0
react-native-create-library: 3.1.2
react-native-git-upgrade: 0.2.7

Description

"Text must not be null or empty" error occurs on Android Studio.

See this issue facebook/react-native#25479

It works for me by updating this code to

def command = "../node_modules/.bin/react-native config"

But react-native run-android does not work fine.

Reproducible Demo

  1. react-native init App
  2. open Android Studio
  3. Gradle Sync failed. (Text must not be null or empty)
@ryohlan ryohlan added the bug Something isn't working label Jul 4, 2019
@thymikee
Copy link
Member

thymikee commented Jul 4, 2019

You'll need to set custom root (likely same for iOS). Here are the docs on it :) https://github.com/react-native-community/cli/blob/master/docs/autolinking.md#custom-root-monorepos-1

@thymikee thymikee closed this as completed Jul 4, 2019
@thymikee
Copy link
Member

thymikee commented Jul 4, 2019

Oh I just thought that outputting a helpful message with autolinking docs link if the config command output is empty would be really helpful. Would you like to contribute that?

@kidandcat

This comment has been minimized.

@mikemcelligott
Copy link

The above did not fix the problem for me, but a similar update is getting me much closer (but still not working app.... and this is a brand new app):

{root}/node_modules/@react-native-community/cli-platform-android/native_modules.gradle:173

-def command = "node ./node_modules/react-native/cli.js config"
+def command = "node ./node_modules/react-native/local-cli/cli.js config"

@ErnesII
Copy link

ErnesII commented Aug 16, 2019

For me it was just something stupid, in the file react-native.config.js, I just commented these lines:

project: {
      ios: {},
      android: {}, // grouped into "project"
    },
commands: require('./path-to-commands.js'),

@tbergquist-godaddy
Copy link

Hi, I am also getting this error, and . I cannot seem to configure it correctly with the current options(I am hoping there is something I missed 😊 )

currently we have a structure like

root/
  node_modules/
  apps/
      web/
      rn-app-1/
      rn-app-2/
  packages/
      shared-components/

Setting root to the project root, it will try to run node ./node_modules/react-native/cli.js config in the project root, and report error on this line : this.packageName = json["project"]["android"]["packageName"].

Setting the root to rn-app-1, gives error on this line def json = new JsonSlurper().parseText(reactNativeConfigOutput)

Both errors makes sense, since the project root does not contain an rn app, and ./node_modules/react-native/cli.js is not a valid path from the workspace root.

What does work is keeping the root at the rn-app-1 workspace and change the command to /node_modules/.bin/react-native config.

I know there is an option using the nohoist of react-native, but I would rather not, since DX is quite bad, we had it before, and upgrading dependencies could take up to 15 minutes ⌛️

So, is there some setting I have missed, or would there be a possibility to add some config to tell rn-cli where to look for the rn-app config?

@tbergquist-godaddy
Copy link

@thymikee @grabbou please ^^ 🙏

@ldco2016
Copy link

@thymikee , how can I confirm if this -> https://github.com/react-native-community/cli/blob/master/docs/autolinking.md#custom-root-monorepos-1

is the issue with Azure DevOps build? I do not get this error locally, but my Azure DevOps person consistently does. Do you or anyone know if the above is something that must be applied when building react-native in Azure?

@alishgiri
Copy link

please first verify the npm -v and node -v gives you some version number.

The problem was with using yarn. I use yarn instead of npm and was getting this error. when I reinstalled node then the problem was resolved. No need to change the node_modules files as it did manage to run but created several other problems later on. Hope this helps yarn lovers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants