4
respostas

ERROR: JAVA_HOME is set to an invalid directory:

JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
4 respostas

Como esta o caminho para o java? (Um exemplo: C:\Program Files\Java\jdk1.8.0_12) Não coloca \bin

which java
/usr/bin/java

sudo update-alternatives --config java
Há 1 escolha para a alternativa java (disponibiliza /usr/bin/java).

  Selecção   Caminho                                  Prioridade Estado
------------------------------------------------------------
  0            /usr/lib/jvm/java-8-oracle/jre/bin/java   1081      modo automático
* 1            /usr/lib/jvm/java-8-oracle/jre/bin/java   1081      modo manual

Press <enter> to keep the current choice[*], or type selection number:

após tirar o /bin apareceu o seguinte:

react-native run-android
Scanning folders for symlinks in /home/christian/Área de Trabalho/Cursos/react-native/HelloWord1/node_modules (11ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'HelloWord1'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find com.android.tools.build:gradle:3.0.1.
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
         https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
     Required by:
         project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

Olá Christin!

Então...

Aparentemente está ocorrendo um problema com o repositório do gradle, você pode postar o seu arquivo build.gradle? Esse arquivo normalmente se encontra em -> NOME-DO-SEU-PROJETO\android\build.gradle

Você também pode tentar usar a versão 3.0.0 do gradle