Build inside android studio works, but failed with command line build
> gradlew tasks
java.lang.UnsupportedClassVersionError:
com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.android"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
The line apply plugin: 'com.android.application'
causes the error. where does the major.minor version 52.0
come from?
make sure gradle plugins are latest:
Fix your JAVA_HOME variable.
The error means there are classes compiled with Java 8 (52.0) that you are trying to use with an older Java version.
When you use Android Studio obviously Java 8 is used to run Gradle, but when you use the Gradle wrapper from commandline, the value of JAVA_HOME is used to execute Gradle.
This is set to Java 7 or older on your machine and thus the build fails as soon as it tries to use the Java class that was compiled with Java 8, in your case a part of the Android Gradle plugin.