Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-native build error Android - java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0

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

like image 393
Mohammed Safeer Avatar asked Dec 24 '22 19:12

Mohammed Safeer


1 Answers

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)

like image 118
Mohammed Safeer Avatar answered Dec 26 '22 10:12

Mohammed Safeer