4
votes

I have setup the react native project as mentioned in react-native documentation (https://facebook.github.io/react-native/docs/getting-started.html). On building using the command react-native run-android, I am getting the following error.

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

FAILURE: Build failed with an exception.

  • Where: Build file '/var/www/html/react-native/NewProject/android/app/build.gradle' line: 1

  • What went wrong: A problem occurred evaluating project ':app'.

    java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0

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

BUILD FAILED

Development Environment

  • Linux
  • Android SDK
  • java version is java version "1.8.0_121"

Android SDK android sdk

Android SDK Build Tools installed 23.0.1, 23.0.2

Could you please someone help me

2

2 Answers

10
votes

At last figured out the problem

check $JAVA_HOME

Need JDK 1.8 to work

Install Java JDK 1.8 and change the JAVA_HOME

edit ~/.bashrc and add JDK 1.8 path as JAVA_HOME

export JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre/

and source ~/.bashrc close the current terminal window/tab and run

react-native run-android

in new tab (ensure $JAVA_HOME set to jdk 1.8 before this)

0
votes

Make sure you have installed and targeting at least Android 6.0 Marshmellow and are using Android SDK Build-Tools 23.0.1.

See React Native setup docs for more information.