1
resposta

erro ao rodar app

Antes estava tudo normal, mas depois de seguir as ultimas alterações eu recebo este erro ao rodar onpx react-native run-android --verbose:

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1033 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
debug Running command "cd android && ./gradlew app:installDebug -PreactNativeDevServerPort=8081"
> Task :react-native-svg:generateDebugRFile FAILED
43 actionable tasks: 2 executed, 41 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-svg:generateDebugRFile'.
> Could not resolve all files for configuration ':react-native-svg:debugCompileClasspath'.
   > Failed to transform react-native-0.71.0-rc.0-debug.aar (com.facebook.react:react-native:0.71.0-rc.0) to match attributes {artifactType=android-symbol-with-package-name, com.android.build.api.attributes.BuildTypeAttr=debug, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
      > Execution failed for JetifyTransform: /home/karl/.gradle/caches/modules-2/files-2.1/com.facebook.react/react-native/0.71.0-rc.0/7a7f5a0af6ebd8eb94f7e5f7495e9d9684b4f543/react-native-0.71.0-rc.0-debug.aar.
         > Java heap space

* 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://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-svg:generateDebugRFile'.
> Could not resolve all files for configuration ':react-native-svg:debugCompileClasspath'.
   > Failed to transform react-native-0.71.0-rc.0-debug.aar (com.facebook.react:react-native:0.71.0-rc.0) to match attributes {artifactType=android-symbol-with-package-name, com.android.build.api.attributes.BuildTypeAttr=debug, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
      > Execution failed for JetifyTransform: /home/karl/.gradle/caches/modules-2/files-2.1/com.facebook.react/react-native/0.71.0-rc.0/7a7f5a0af6ebd8eb94f7e5f7495e9d9684b4f543/react-native-0.71.0-rc.0-debug.aar.
         > Java heap space

* 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 makeError (/home/karl/projetos/mobile/navegacao/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
    at /home/karl/projetos/mobile/navegacao/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 (/home/karl/projetos/mobile/navegacao/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
    at async Command.handleAction (/home/karl/projetos/mobile/navegacao/node_modules/@react-native-community/cli/build/index.js:192:9)

repositório:https://github.com/karlgama/react-native-navegacao

1 resposta

Olá, Kaique!

Pelo erro apresentado, parece que há um problema com a biblioteca react-native-svg durante a execução do comando npx react-native run-android --verbose. O erro específico é "Java heap space", o que indica que há um problema de memória durante a execução.

Uma possível solução para esse problema é aumentar o tamanho da memória heap do Gradle. Você pode fazer isso adicionando a seguinte linha de código no arquivo android/gradle.properties do seu projeto:

org.gradle.jvmargs=-Xmx4096m

Isso aumentará o tamanho da memória heap para 4GB. Se o problema persistir, você pode tentar aumentar ainda mais esse valor.

Além disso, certifique-se de ter configurado corretamente o ambiente de desenvolvimento Android, como mencionado no link que você compartilhou: https://reactnative.dev/docs/environment-setup.

Espero que isso ajude a resolver o problema! Se você tiver mais alguma dúvida, fique à vontade para perguntar. Estou aqui para ajudar.

Espero ter ajudado e bons estudos!