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 #25479

Closed
yjqz86 opened this issue Jul 3, 2019 · 39 comments
Closed

> Text must not be null or empty #25479

yjqz86 opened this issue Jul 3, 2019 · 39 comments
Labels
Bug Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@yjqz86
Copy link

yjqz86 commented Jul 3, 2019

When I execute react-native run-android. I have the following:

FAILURE: Build failed with an exception.

  • Where:
    Script 'C:\Users\zenz\programs\test_app\node_modules@react-native-community\cli-platform-android\native_modules.gradle' line: 182

  • What went wrong:
    A problem occurred evaluating settings 'test_app'.

Text must not be null or empty

  • 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

After I try to make in file 'node_modules@react-native-community\cli-platform-android\native_modules.gradle:

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

It does not work for me. I need help

@yjqz86 yjqz86 added the Bug label Jul 3, 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 Jul 3, 2019
@yjqz86
Copy link
Author

yjqz86 commented Jul 3, 2019

I hope this capture can help

bugReactive

@ryohlan
Copy link

ryohlan commented Jul 4, 2019

I found the cause.

This is issue for react-native-community/cli-platform-android. See below

https://github.com/react-native-community/cli/blob/master/packages/platform-android/native_modules.gradle#L170

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

It works for me.

@kidandcat
Copy link

I confirm it works with def command = "../node_modules/.bin/react-native config".

@ryohlan
Copy link

ryohlan commented Jul 4, 2019

My solution is not correct.

This is auto linkikg issue.

Read this comment. react-native-community/cli#468 (comment)

@kidandcat
Copy link

kidandcat commented Jul 4, 2019

No, it doesn't work without the change you proposed. I saw that issue, but my project is a clean install with react-native init, I haven't a different structure.

With your change it is working for me, but because it fails to execute that step:

:ReactNative:Cannot run program "../node_modules/.bin/react-native" (in directory "C:\Users\jairo\Desktop\racctrips2\android\.."): CreateProcess error=193, %1 no es una aplicaci¾n Win32 vßlida
:ReactNative:Automatic import of native modules failed.

@thymikee
Copy link
Contributor

thymikee commented Jul 4, 2019

@kidandcat in default template, there's no ../node_modules/.bin/react-native, it's ./node_modules/.bin/react-native. Are you sure you didn't modify it/cache it somewhow?

@kidandcat
Copy link

kidandcat commented Jul 4, 2019

Yeah, in default template is node ./node_modules/.bin/react-native and it fails with Text must not be null or empty, I modified it to ../node_modules/.bin/react-native as @ryohlan suggested

The exact error I'm getting:

Script 'C:\Users\jairo\Desktop\racctrips2\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 182

* What went wrong:
A problem occurred evaluating settings 'racctrips2'.
> Text must not be null or empty

@thymikee
Copy link
Contributor

thymikee commented Jul 4, 2019

@kidandcat we recently released a fix for that. Please init once again and verify

@leejh1117
Copy link

I was solved after install @react-native-community/cli

@kidandcat
Copy link

Wow, that was very recently, I initialized it yesterday. Thanks @thymikee its working now!

@thymikee
Copy link
Contributor

thymikee commented Jul 4, 2019

Closing as resolved then :)

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

alindima commented Jul 4, 2019

I have the same issue. What do you mean by "init once again"?

@thymikee
Copy link
Contributor

thymikee commented Jul 4, 2019

I referred to the fact that the faulty project was created through init yesterday, before a fix in the cli was published. What you can do in existing codebase is make sure @react-native-community/cli is at 2.0.2 version (check the lock file, remove the cli entry and reinstall packages so the newest version is fetched)

@acro5piano
Copy link

acro5piano commented Jul 6, 2019

For those who are working with "standard" monorepo structure, like

packages/
  |- app1/
  |  |- package.json
  |  |- ios/
  |  |- src/
  |  `- android/
  `- app2/
     |- package.json
    // ...

Try the following settings.

app1/android/settings.gradle

apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesSettingsGradle(settings, "../../../packages/app1");

app1/android/app/build.gradle

apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesAppBuildGradle(project, "../../../packages/app1");

Detail

I tried settings described here , then another error showed up:

A problem occurred evaluating settings 'Example'.
> Cannot get property 'packageName' on null object

Also, I checked node_modules/@react-native-community/cli-platform-android/native_modules.gradle and found the configuration which is brought by node ./node_modules/react-native/cli.js config is wrong only if we do monorepo structure:

    this.packageName = json["project"]["android"]["packageName"]
// node ./node_modules/react-native/cli.js config

{
  "root": "/path/to/myapp",
  "reactNativePath": "/path/to/myapp/node_modules/react-native",
  "dependencies": {},
  "commands": [],
  "assets": [],
  "platforms": {},
  "haste": {
    "providesModuleNodeModules": [],
    "platforms": []
  },
  "project": {}
}

So I came up to the solution.

@olistic
Copy link

olistic commented Jul 8, 2019

@acro5piano I'm on the same situation than you, but it's not clear to me from you message what is the solution that worked for you. Could you please give more details? Thanks :)

@acro5piano
Copy link

acro5piano commented Jul 8, 2019

@olistic I updated my comment above. I made it a little bit clear and fix some typos.

In short,

  • applyNativeModulesSettingsGradle and applyNativeModulesAppBuildGradle will look up the output of node ./node_modules/react-native/cli.js config by default
  • In monorepo projects, the output of the command is different from single package projects, because cli.js will look up ../../ as project root by default
  • So, adding project root path to these functions fixes the issue

For more information, please refer to the cli package's source code.

https://github.com/react-native-community/cli/blob/master/packages/platform-android/native_modules.gradle#L177

@olistic
Copy link

olistic commented Jul 8, 2019

@acro5piano Thank you! So basically what's different between what's explained here and what ended up working for you is:

// app1/android/settings.gradle
-applyNativeModulesSettingsGradle(settings, "../../..")
+applyNativeModulesSettingsGradle(settings, "../../../packages/app1")

(and the analogous for applyNativeModulesAppBuildGradle)

For some reason that is not working for me. In my case, my monorepo structure doesn't have a packages directory, it's just:

.
├── node_modules  <- where `react-native` is installed.
├── api
├── native  <- the React Native app
├── web
├── lerna.json
└── package.json

When I was using 0.59, I followed this tutorial which worked fine. With 0.60 and the new CLI 2.0 I was trying to apply those same steps plus some variations I found necessary, but I'm stuck at this point. I will keep researching.

@acro5piano
Copy link

acro5piano commented Jul 8, 2019

@olistic
You're welcome!

Thank you! So basically what's different between what's explained here and what ended up working for you is:

Yes.
I think applyNativeModulesSettingsGradle(settings, "../../../native") will work, but React Native projects tend to be subjected to our "versions".
Actually I had another problem after I updated from 0.57.7 to 0.60.0 and clouldn't solve, so I finally dicided to update to 0.59.10.
I will wait enough information to upgrade to 0.60.0 as the version is still quite a new release.

Thank you for your researching. Good luck.

@thymikee
Copy link
Contributor

thymikee commented Jul 8, 2019

@acro5piano @olistic I've updated the autolinking guide to provide some more information about how it's set up currently in the default template and when having custom root: react-native-community/cli#505. Hope that clears some confusions. If you have ideas on how to make it more approachable, I'd be glad to include them :)

@mattijsf
Copy link
Contributor

mattijsf commented Jul 17, 2019

I also got the Cannot get property 'packageName' on null object.

We have two separate repo for Android / iOS with each a submodule pointing towards the shared react-native git submodule.

This the structure on the Android project:

root/
  |- app/
    |- build.gradle
  |- setting.gradle
  |- react-native/ (git submodule)
    |- node_modules/
    |- package.json

Given the above structure, this is how I defined my gradle files:

/settings.gradle:

apply from: file("react-native/node_modules/@react-native-community/cli-platform-android/native_modules.gradle")
applyNativeModulesSettingsGradle(settings, "react-native/")

/app/build.gradle:

apply from: file("../react-native/node_modules/@react-native-community/cli-platform-android/native_modules.gradle")
applyNativeModulesAppBuildGradle(project, "react-native/")

I believe the paths above are correct for that project structure because otherwise I get the Text must not be null or empty message.

Any help is welcome 👍

@thymikee
Copy link
Contributor

@mattijsf your project structure is not quite common. CLI can't figure out where you android project is. Try running yarn react-native config and see the output, the project needs to be populated. You should find this docs helpful in adjusting the project config: https://github.com/react-native-community/cli/blob/master/docs/projects.md.

@DylanVann
Copy link
Contributor

DylanVann commented Jul 21, 2019

I still can't make the packages/Project setup work.

I made a repo trying to do it. DemoProject was just created by the cli, no modifications. Here is the commit modifying build.gradle and settings.gradle - https://github.com/DylanVann/react-native-monorepo-example/commit/e4bea7801dee2d19a17a29f93ce48725aaf3fee8

With this setup I still get:

A problem occurred evaluating settings 'DemoProject'.
> Text must not be null or empty

image

@ldco2016
Copy link

ldco2016 commented Jul 31, 2019

Okay I just read everything above and I find it clear as mud. Sorry, perhaps someone can provide clarity.

I have this error in my Jenkins build only:

13:18:22 FAILURE: Build failed with an exception.
13:18:22 
13:18:22 * Where:
13:18:22 Script '/Users/nfib/Jenkins/Jenkins-Workspaces/ENGA/ENGAL/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 190
13:18:22 
13:18:22 * What went wrong:
13:18:22 A problem occurred evaluating settings 'NFIBEngage'.
13:18:22 > Text must not be null or empty

Others mentioned something about app/build.gradle, here is the relevant part of mine:

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

Mention was also made of android/settings.gradle, this one is mine:

rootProject.name = 'NFIBEngage'
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':appcenter-crashes'
project(':appcenter-crashes').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter-crashes/android')
include ':appcenter-analytics'
project(':appcenter-analytics').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter-analytics/android')
include ':appcenter'
project(':appcenter').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter/android')
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

From what I have gathered here:
https://react-native-community.github.io/upgrade-helper/?from=0.53.3&to=0.60.4

The above file is correct.

So what exactly is wrong here and how do I fix it?

In terms of node_modules/@react-native-community/cli-platform-android/native_modules.gradle line 190 is this one:

def json = new JsonSlurper().parseText(reactNativeConfigOutput)

The solution that @ryohlan gives is not the line of code that my error is complaining about.

@implsoftware
Copy link

Still able to reproduce the issue with v2.8.3. Should this be re-opened since there are still a few folks experiencing the issue - @thymikee ?

@thymikee
Copy link
Contributor

thymikee commented Aug 4, 2019

I'm not gonna reopen this. People face this issue for different reasons. Please create a new issue with a detailed description and a repro we can download and investigate.

@implsoftware
Copy link

Will do, thx

@ldco2016
Copy link

ldco2016 commented Aug 7, 2019

@thymikee

I referred to the fact that the faulty project was created through init yesterday, before a fix in the cli was published. What you can do in existing codebase is make sure @react-native-community/cli is at 2.0.2 version (check the lock file, remove the cli entry and reinstall packages so the newest version is fetched)

I tried this and the newest version is not fetched, it continues to fetch version ^2.0.1.

@peterng014
Copy link

I confirm it works with def command = "../node_modules/.bin/react-native config"
react-native: 0.61.2

@rohanrvpatil
Copy link

I found the cause.

This is issue for react-native-community/cli-platform-android. See below

https://github.com/react-native-community/cli/blob/master/packages/platform-android/native_modules.gradle#L170

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

It works for me.

Where do we put this 'def command' line??

@sumudu-dewasurendra
Copy link

@runny2018 edit native_modules.gradle file located at ..\node_modules@react-native-community\cli-platform-android

@thymikee
Copy link
Contributor

Instead of mangling in node_modules, please update the @react-native-community/cli to the latest version. We've recently improved the way we handle running configuration from native modules, which likely fixes your issues.

@sgeier
Copy link

sgeier commented Oct 16, 2019

Unfortunately upgrading the cli doesn't fix the problem.

I am including in the settings.gradle at the bottom:
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

The error message produced is:
org.gradle.internal.exceptions.LocationAwareException: Script '/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 182

Caused by: java.lang.IllegalArgumentException: Text must not be null or empty
	at ReactNativeModules.getReactNativeConfig(/Users/user/Projects/projectname/node_modules/@react-native-community/cli-platform-android/native_modules.gradle:182)

Line 182 boils down to:
def json = new JsonSlurper().parseText(reactNativeConfigOutput)

I verified I had the latest version:

 UNMET PEER DEPENDENCY react-native@0.61.2
  └── @react-native-community/cli@3.0.0-alpha.7

Any help appreciated.

@thymikee
Copy link
Contributor

@sgeier please create a new issue in https://github.com/react-native-community/cli/ repo, with a minimal reproduction of your project structure. Otherwise we can't help.

@sgeier
Copy link

sgeier commented Oct 17, 2019

In another thread grabbou wrote that this error comes up when "project.android" is not properly set or something. Can you point me to where this config is read out?
Thanks

@borapop
Copy link

borapop commented Oct 22, 2019

@thymikee double check that there is no react-native-cli in package.json. If there is, remove it.

@lucasfp13
Copy link

lucasfp13 commented Oct 25, 2019

@borapop it works for me, thank you so much!!

@laogui
Copy link

laogui commented Nov 5, 2019

It happened in cli-platform-android@3.0.0-alpha.7.

npm i --no-save @react-native-community/cli-platform-android@3.0.0-alpha.2
npx react-native start --reset-cache

It worked for me.

@Keurdange
Copy link

I was solved after install @react-native-community/cli
This works for me

@facebook facebook locked as resolved and limited conversation to collaborators Jul 4, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug 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