0
apply plugin: 'com.android.application'
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 23
    }
    dataBinding {
        enabled = true
    }
}

This is my build.gradle.It's compile success in Android Studio. But when I run on ./gradlew build terminal. It was build error. The error:

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

java -version

java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

./gradlew -v

------------------------------------------------------------
Gradle 2.14.1
------------------------------------------------------------

Build time:   2016-07-18 06:38:37 UTC
Revision:     d9e2113d9fb05a5caabba61798bdb8dfdca83719

Groovy:       2.4.4
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.7.0_71 (Oracle Corporation 24.71-b01)
OS:           Mac OS X 10.11.4 x86_64
Xie Tom
  • 3
  • 3
  • Possible duplicate of [How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version](http://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi) – Code-Apprentice Sep 29 '16 at 04:06

1 Answers1

0

52.0 is the compatibility version of Java 8, so it seems the android build system was compiled with Java 8. This means it simply won't run on a Java 7 VM.

Kiskae
  • 24,655
  • 2
  • 77
  • 74
  • My Java Version is 1.7~And It build success on Android Studio. – Xie Tom Sep 29 '16 at 02:57
  • @XieTom Then Android Studio internally uses its own Java 8 JRE to run its tools. There is no way for `52.0` bytecode to run on an earlier version. – Kiskae Sep 29 '16 at 02:59