Error Trying to Run React Native project on Android physical device

Asked

Viewed 356 times

-2

I am trying to start a React-Native project 3 days ago on my PC to run on my Android physical device. While running the project with npx react-native run-android appear the following logs:

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...
:ReactNative:Unexpected empty result of running '[node, C:\Users\Pichau\Programação\Projetos\JavaScript\ControleDePagamentos-GrupoDaAgua\mobile2\node_modules\@react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\Pichau\Programação\Projetos\JavaScript\ControleDePagamentos-GrupoDaAgua\mobile2\node_modules\@react-native-community\cli\build\bin.js, config]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\Pichau\Programa��o\Projetos\JavaScript\ControleDePagamentos-GrupoDaAgua\mobile2\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 195

* What went wrong:
A problem occurred evaluating script.
> internal/modules/cjs/loader.js:984  throw err;  ^Error: Cannot find module 'C:\Users\Pichau\Programação\Projetos\JavaScript\ControleDePagamentos-GrupoDaAgua\mobile2\node_modules\@react-native-community\cli\build\bin.js'    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:981:15)    at Function.Module._load (internal/modules/cjs/loader.js:863:27)    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)    at internal/main/run_main_module.js:18:47 {  code: 'MODULE_NOT_FOUND',  requireStack: []}

* 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://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Unexpected empty result of running '[node, C:\Users\Pichau\Programação\Projetos\JavaScript\ControleDePagamentos-GrupoDaAgua\mobile2\node_modules\@react-native-community\cli\build\bin.js, config]' command.

I tried to change the environment variables and everything else, but the error persists. (I followed the tutorial of the documentation of React Native) Can you help me, please?

1 answer

1


Edit

Check the path where your project is located and try to put in a folder that does not contain special characters, in your case it would be the folder "Programming". Rename this folder to "programming" without accents or create the project elsewhere (ex C: project programming).

Look, did you ever test all the tools needed for React Native to work? Ideally you would run the commands in the terminal:

node -v
javac -version
python --version

If all the above commands work correctly, showing each one’s version, make sure that Node is in LTS version, that Java is in version 8 (It might show something like 1.8.0) and that Python is in version 2. If all this is right, you need to check if your Android SDK installation is correct. A simple way to check this is by running the command:

adb devices

If nothing happens or an error message appears, that is to say you have some problem in installing the Android SDK, recommend you look at your environment variables and if installed everything needed by Android Studio.

If all the above steps are correct and the error still persists, try creating

  • All the above commands work correctly and all with the correct versions (jdk8, python 2, Node LTS). adb devices shows my device (and yes, with the "device" written on the side). I created a new project in the same folder and the error persists. I’m sorry, but I don’t know how to describe the problem better.

  • Look, I think I figured out the cause of your problem, I thought it might be something related to the development environment. But the truth is where your folder is located. Try to put your project in a place that has no special characters folder, in your case, you wrote "Programming" in a folder, and I believe this may be causing the problem.

  • Thank you very much! The problem was in the folder name as you well noted.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.