My task is to build an apk
file using gradle wrapper via command line. I have a project in Android Studio 2.2.3
, it has a line in build.gradle file classpath 'com.android.tools.build:gradle:2.2.3'
, which should mean, that it is using gradle version 2.2.3. But when I call gradlew command from the project folder, there is always the same error: Unsupported major.minor version 52.0
I've used gradlew -v
to recognize my gradle version, it is now 2.2.1
. Though when I manually change gradle version in build.gradle file from 2.2.3
to 2.2.1
I still get the same error.
I checked the folder containing gradle on my computer. It has gradle version 2.14.1
.
I tried:
changing JDK path from 1.7 to 1.8 (JAVA_HOME variable)
manually changing JDK location at Project Structure -> SDK Location settings
- in gradle settings: switching between using default gradle wrapper and local gradle distribution.
Interesting thing is that when I change gradle version in build.gradle to 1.5.0
the version error disappears, but I can no longer make any builds(it becomes unable to merge several jar
files into one apk
file)
What is this version hell and how do I get rid of this error?
EDIT #1:
My /gradle/wrapper/gradle-wrapper.properties content is:
#Fri Oct 21 12:53:56 EEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
EDIT #2:
I figured out that gradle versions are the same. So what JDK and JRE version should I use and how do I update them? Simply downloading into Java folder and changing JDK location in Project Structure didn't help.
EDIT #3:
My build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:1.5.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My project-level build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.test.test"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:design:23.4.0'
compile "com.android.support:support-v4:23.4.0"
compile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
SOLUTION:
I needed to update targetSdkVersion and all dependencies to version 25 and set JAVA_HOME to jdk 1.8. Thanks, Abhishek Aryan