0

I created a react-native project with npx react-native init myApp, set up ANDROID_HOME and JAVA_HOME variables in enviroment variables, installed Android Studio, downloaded everything needed (Chocolatey, Node.js, Python 2, Openjdk11). But when I run the command

npx react-native run-android

it doesn't start the project. It opens android emulator but I got this error below in console. What I tried so far:

Change / in settings.graddle

Delete node_modules, package.json.lock and reinstall everything

Start other project

Reinstall Android Studio

Invalidate Caches in Android Studio

Uninstall and install @react-native-community/cli-platform-android

Console error:

PS C:\Users\myusername\OneDrive\Work Área\work\react-native\app\myApp> npx react-native run-android
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 946 file(s) to forward-jetify. Using 16 workers...
info Starting JS server...
info Installing the app...
:ReactNative:Unexpected empty result of running '[node, C:\Users\myusername\OneDrive\Work Área\work\react-native\app\myApp\node_modules\@react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\myusername\OneDrive\Work Área\work\react-native\app\myApp\node_modules\@react-native-community\cli\build\bin.js, config]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\myusername\OneDrive\Work Áreao\work\react-native\app\myApp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 213

* What went wrong:
A problem occurred evaluating script.
> node:internal/modules/cjs/loader:936  throw err;  ^Error: Cannot find module 'C:\Users\myusername\OneDrive\ÃWork Áreao\work\react-native\app\myApp\node_modules\@react-native-community\cli\build\bin.js'    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)    at Function.Module._load (node:internal/modules/cjs/loader:778:27)    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)   
 at node:internal/main/run_main_module:17: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.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Unexpected empty result of running '[node, C:\Users\myusername\OneDrive\Work Área\work\react-native\app\myApp\node_modules\@react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\myusername\OneDrive\Work Área\work\react-native\app\myApp\node_modules\@react-native-community\cli\build\bin.js, config]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\myusername\OneDrive\Work Áreao\work\react-native\app\myApp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 213

* What went wrong:
A problem occurred evaluating script.
> node:internal/modules/cjs/loader:936  throw err;  ^Error: Cannot find module 'C:\Users\myusername\OneDrive\ÃWork Áreao\work\react-native\app\myApp\node_modules\@react-native-community\cli\build\bin.js'    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)    at Function.Module._load (node:internal/modules/cjs/loader:778:27)    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)   
 at node:internal/main/run_main_module:17: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

    at makeError (C:\Users\myusername\OneDrive\Work Área\work\react-native\app\myApp\node_modules\execa\index.js:174:9)
    at C:\Users\myusername\OneDrive\Work Área\work\react-native\app\myApp\node_modules\execa\index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (C:\Users\myusername\OneDrive\Work Área\work\react-native\app\myApp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
    at async Command.handleAction (C:\Users\myusername\OneDrive\Work Área\work\react-native\app\myApp\node_modules\@react-native-community\cli\build\index.js:192:9)  
info Run CLI with --verbose flag for more details.

enter image description here

enter image description here

enter image description here

enter image description here

1 Answer 1

1

Open Android Studio File -> Project Structure -> Gradle Settings -> Gradle JDK

and set up as

Embedded JDK

This worked for me after trying so many other options.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.