1
resposta

npx react-native run-android não funciona

Segue erro

PS C:\Users\mariana.teixeira\Lighteria> npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 860 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...
> Task :app:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
13 actionable tasks: 13 executed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that C:\Program Files\AdoptOpenJDK\jre-8.0.265.01-hotspot contains a valid JDK installation.

* 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 7s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that C:\Program Files\AdoptOpenJDK\jre-8.0.265.01-hotspot contains a valid JDK installation.

* 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 7s

    at checkExecSyncError (node:child_process:826:11)
    at execFileSync (node:child_process:864:15)
    at runOnAllDevices (C:\Users\mariana.teixeira\Lighteria\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
    at buildAndRun (C:\Users\mariana.teixeira\Lighteria\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
    at C:\Users\mariana.teixeira\Lighteria\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Command.handleAction (C:\Users\mariana.teixeira\Lighteria\node_modules\@react-native-community\cli\build\cliEntry.js:160:7)
1 resposta

Olá Mariana, tudo bem?

Podem ser pequenos detalhes que estão causando esse problema. Para eu te ajudar a resolver isso vou precisar que você faça algumas coisas para mim. Abra o seu terminal e digite:

node -v

Qual versão do node aparece no terminal?

Depois digite:

java -version

Qual versão do java que aparece no terminal?

E por fim, me diga uma coisa, quando você tentou rodar a aplicação você fez esse passo a passo aqui?:

  1. Primeiro abriu o emulador Android e já deixou ele ligado;
  2. Abriu dois terminais dentro da pasta do projeto React Native criado;
  3. No primeiro terminal digitou:
    npm start
  4. E depois no segundo terminal digitou:
    npx react-native run-android

Foram esses passos que você fez? Fico no aguardo.