4

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 Answers 2

10

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)

Sign up to request clarification or add additional context in comments.

2 Comments

Incase anyone else struggles with this, I had to go download jdk1.8 from Oracle on Mac. Android Studio was using 1.7.x.
Yes I was using Jdk 1.6. Updating to jdk 1.8 helped me a lot.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.