Search code examples
reactjsreact-nativeandroid-emulatorjava-10

React native Could not determine java version from '10'


I am having a hard time trying to configure my emulator with react native. I already have the emulator installed but can't properly run the statement: react-native run-android this is the error I keep getting. (p.s. there seems to be no solutions in the troubleshoot. I have tried to change the gradle-properties which was ineffective)

C:\Users\Dell\AwesomeProject>react-native run-android
Scanning folders for symlinks in C:\Users\Dell\AwesomeProject\node_modules (31ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...

FAILURE: Build failed with an exception.
  • What went wrong: Could not determine java version from '10'.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 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


Solution

  • I had the same issue. After upgrading to Ubuntu Bionic which comes with Java 10 which is not supported by react-native.

    I'm using the following script now:

    #!/bin/bash
    export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/
    export PATH=$JAVA_HOME/bin:$PATH
    react-native run-android
    

    I change the env path to Java 8 and run the app.