2
respostas

Problemas pra rodar "npx react-native run-android"

Fala galera, estou atualmente no curso de React-Native Utilizando e criando Hooks.

quando tento rodar no terminal: npx react-native run-android

apresenta as mensagens abaixo:

1º PARTE

PS C:\Alura\REACT_NATIVE\react-native-cli\orgsHooks> npx react-native run-android info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag. Jetifier found 874 file(s) to forward-jetify. Using 8 workers... info JS server already running. O sistema n�o pode encontrar o caminho especificado. info Launching emulator... error Failed to launch emulator. Reason: No emulators found as an output of emulator -list-avds. warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch. info Installing the app... Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01 Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01 Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Observed package id 'platform-tools' in inconsistent location 'C:\Users\jonatas.almeida\AppData\Local\Android\Sdk\platform-tools' (Expected 'C:\Users\jonatas.almeida\AppData\Local\Android\Sdk\platform-tools\platform-tools') Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01 Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01 Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Observed package id 'platform-tools' in inconsistent location 'C:\Users\jonatas.almeida\AppData\Local\Android\Sdk\platform-tools' (Expected 'C:\Users\jonatas.almeida\AppData\Local\Android\Sdk\platform-tools\platform-tools') File C:\Users\jonatas.almeida.android\repositories.cfg could not be loaded. Checking the license for package SDK Patch Applier v4 in C:\Users\jonatas.almeida\AppData\Local\Android\Sdk\platform-tools\licenses Warning: License for package SDK Patch Applier v4 not accepted. Checking the license for package Android Emulator in C:\Users\jonatas.almeida\AppData\Local\Android\Sdk\platform-tools\licensesWarning: License for package Android Emulator not accepted. Checking the license for package Android SDK Tools in C:\Users\jonatas.almeida\AppData\Local\Android\Sdk\platform-tools\licenses Warning: License for package Android SDK Tools not accepted. Checking the license for package Android SDK Build-Tools 30.0.2 in C:\Users\jonatas.almeida\AppData\Local\Android\Sdk\platform-tools\licenses Warning: License for package Android SDK Build-Tools 30.0.2 not accepted. Checking the license for package Android SDK Platform 30 in C:\Users\jonatas.almeida\AppData\Local\Android\Sdk\platform-tools\licenses Warning: License for package Android SDK Platform 30 not accepted.

FAILURE: Build failed with an exception.

2 respostas

2º PARTE

  • What went wrong: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

    Failed to install the following Android SDK packages as some licences have not been accepted. patcher;v4 SDK Patch Applier v4 platforms;android-30 Android SDK Platform 30 build-tools;30.0.2 Android SDK Build-Tools 30.0.2 emulator Android Emulator tools Android SDK Tools To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager. Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

    Using Android SDK: C:\Users\jonatas.almeida\AppData\Local\Android\Sdk\platform-tools

  • 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 1m 5s

error Failed to install the app. Please accept all necessary Android SDK licenses using Android SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses". Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • What went wrong: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

    Failed to install the following Android SDK packages as some licences have not been accepted. patcher;v4 SDK Patch Applier v4 platforms;android-30 Android SDK Platform 30 build-tools;30.0.2 Android SDK Build-Tools 30.0.2 emulator Android Emulator tools Android SDK Tools To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager. Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

    Using Android SDK: C:\Users\jonatas.almeida\AppData\Local\Android\Sdk\platform-tools

  • 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 1m 5s

at makeError (C:\Alura\REACT_NATIVE\react-native-cli\orgsHooks\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at C:\Alura\REACT_NATIVE\react-native-cli\orgsHooks\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (C:\Alura\REACT_NATIVE\react-native-cli\orgsHooks\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Alura\REACT_NATIVE\react-native-cli\orgsHooks\node_modules\@react-native-community\cli\build\index.js:192:9)

info Run CLI with --verbose flag for more details.

O que pode estar acontecendo, já tentei o google pelo menos nas mensagens de erro principais, mas fiquei mais confuso que tudo na vida

Olá, Luciana!

Parece que você está enfrentando alguns problemas ao tentar rodar o comando "npx react-native run-android". Vamos tentar resolver isso juntas!

Pelos logs que você compartilhou, parece que o erro está relacionado à falta de emuladores ou dispositivos conectados. O comando está tentando iniciar um emulador automaticamente, mas não está encontrando nenhum disponível.

Uma possível solução seria iniciar manualmente um emulador antes de rodar o comando. Você pode fazer isso abrindo o Android Studio, clicando em "AVD Manager" e iniciando um emulador a partir daí. Certifique-se de que o emulador esteja completamente iniciado antes de rodar o comando novamente.

Outro ponto que pode estar causando problemas é a aceitação das licenças do Android SDK. O comando está verificando as licenças e parece que algumas não foram aceitas. Você pode tentar aceitar as licenças manualmente executando o seguinte comando no terminal:

sdkmanager --licenses

Isso abrirá um prompt onde você poderá aceitar as licenças necessárias. Certifique-se de aceitar todas as licenças solicitadas.

Se mesmo assim o problema persistir, pode ser necessário verificar a instalação do Android SDK e garantir que todas as dependências estejam corretamente configuradas.

Espero que essas sugestões possam te ajudar a resolver o problema! Se tiver mais alguma dúvida, é só me perguntar. Estou aqui para ajudar!

Espero ter ajudado e bons estudos!