1
resposta

Erro ao executar o comando react-native run-android

Bom dia, estou com o seguinte erro:

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\Nile\react-native\InstaluraMobile\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 200

* What went wrong:
A problem occurred evaluating script.
> Failed to parse React Native CLI configuration. Expected running 'npx.cmd --quiet --no-install react-native config' command from 'C:\Users\Nile\react-native\InstaluraMobile' directory to output valid JSON, but it didn't. This may be caused by npx resolving to a legacy global react-native binary. Please make sure to uninstall any global 'react-native' binaries: 'npm uninstall -g react-native react-native-cli' and try again

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

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
:ReactNative:Failed to parse React Native CLI configuration: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object

The current character read is 'C' with an int value of 67
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0

Segue o resumo do react-native info:

C:\Users\Nile\react-native\InstaluraMobile>react-native info
info Fetching system and libraries information...
System:
    OS: Windows 10 10.0.18362
    CPU: (4) x64 Intel(R) Core(TM) i5-4690 CPU @ 3.50GHz
    Memory: 1.39 GB / 7.93 GB
  Binaries:
    Node: 13.7.0 - C:\Program Files\nodejs\node.EXE
    Yarn: yarn install v0.24.6
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.89s. - C:\Users\Nile\AppData\Roaming\npm\yarn.CMD
    npm: 6.13.6 - C:\Program Files\nodejs\npm.CMD
  SDKs:
    Android SDK:
      API Levels: 23, 29
      Build Tools: 23.0.1, 29.0.3
      System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: Version  3.5.0.0 AI-191.8026.42.35.6010548
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.5 => 0.61.5
1 resposta

Raphael, boa tarde!

Infelizmente eu não consegui reproduzir o erro, uma solução que encontrei foi, remover a pasta de compilação (build) dentro do android e ir para a pasta android e, e no terminal, digitar ./gradlew clean e depois cd.. e npx react-native run-android

Mas é realmente uma tentativa, qualquer coisa manda uma mensagem aqui que iremos te ajudar

Espero ter ajudado e bons estudos!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software