Skip to content

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

Closed

Description

@ryohlan

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 react/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)

Activity

  1. thymikee commented on Jul 4, 2019

    @thymikee
    Member

    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

  2. thymikee commented on Jul 4, 2019

    @thymikee
    Member

    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?

  3. kidandcat commented on Jul 4, 2019

    @kidandcat
  4. mikemcelligott commented on Aug 14, 2019

    @mikemcelligott

    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"

  5. ErnesII commented on Aug 16, 2019

    @ErnesII

    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'),
    
  6. tbergquist-godaddy commented on Aug 27, 2019

    @tbergquist-godaddy

    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?

  7. tbergquist-godaddy commented on Aug 28, 2019

    @tbergquist-godaddy

    @thymikee @grabbou please ^^ 🙏

  8. ldco2016 commented on Sep 27, 2019

    @ldco2016

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

  9. alishgiri commented on Nov 2, 2019

    @alishgiri

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions