1

Hello to all who are interesting in the issue,

I feel confused about gradle version in Android studio.

I am using the Android Studio 2.2.2. In the project build.gradle. I have classpath 'com.android.tools.build:gradle:2.2.2 which makes me believing the Android studio is using gradle 2.2.2.

In the gradle-wrapper.properties, It has https\://services.gradle.org/distributions/gradle-2.14.1-all.zip. So it means the gradlew build scripts requires 2.14.

When I tried to list tasks in the project, I used the terminal gradle tasks, I had following error:

java.lang.UnsupportedClassVersionError: com/android/build/gradle/LibraryPlugin : Unsupported major.minor version 52.0

And when I run gradlew -v I found the gradle version is 2.10. It could be me, I manually install the gradle by using apt-get install gradle. The default version might be 2.10.

My question is, which version gradle the android studio is using and how can I update the gradle to 'correct' version so I could list the tasks in the android project?

Edit 1:
I tried to update gradle to 2.14. By using sudo apt-cache search gradle sudo add-apt-repository ppa:cwchien/gradle sudo apt-get update sudo apt-get install gradle-2.14

I also tried to upgrade the gradle to version 2.14.1, but still having the same error.
Thanks for your help

Rong


A solution of solving the version 52.0 issue One suggested solution (with the similar situation I am having) solved the problem by decrease the gradle version to 2.10, I really do not want to do that, since I wish to use the update-to-date version that android studio is using.

As to the solution solved that issue: I am already having the Android 6.0 API 23 installed in the Android studio. The Android SDK 6.0 does not fix the problem in my case.


environment: Android studio 2.2.2
Java sdk: 1.7
OS: Ubuntu 16.04 LTS

Community
  • 1
  • 1
r0n9
  • 2,505
  • 1
  • 29
  • 43

2 Answers2

1

Got it work Thanks. I installed both java 1.7 and 1.8 and I was using 1.7 in the terminal by using sudo update-alternatives --config javac. By some reason, I believe the android uses java 1.8. I changed update-alternatives option to java 1.8. The command 'gradlew tasks' starting to work as expected.

r0n9
  • 2,505
  • 1
  • 29
  • 43
  • [This thread](http://stackoverflow.com/questions/25260172/how-to-check-the-gradle-version-in-android-studio) shows a way to check gradle version in the Android studio. It works in android studio 2.2.2. – r0n9 Oct 31 '16 at 00:36
1

yes, but update $JAVA_HOME$ also accordingly.

Thara Perera
  • 574
  • 6
  • 6