3

After trying to build my project in Mac OS X El Capitan I've got this error:

Error:Gradle: A problem occurred configuring project ':app'. Buildtools 24.0.2 requires Java 1.8 or above. Current JDK version is 1.7.

I have project with build.gradle section like this:

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
}

Also:

Project SDK 1.8.0_101

App Module: android sdk 24, jdk 1.8,

Root Module: android sdk 24, jdk 1.8

compileSdkVersion 24

buildToolsVersion '24.0.2'

minSdkVersion 16

targetSdkVersion 24

retrolambda

P.S.: I successfully built this project from command line.

Community
  • 1
  • 1

3 Answers3

6

Since you successfully built it in the command line, it seems like it's a problem with your project JDK. The JDK location setting is located in File>Project Structure>SDK Location --> JDK Location. If it says anything about jdk1.7.0, then switch the jdk to 1.8 by clicking the ... button to the right of the prompt and give it the file path of jdk1.8.

EDIT: If you don't know the path of the jdk, run ls -l 'which java' in the terminal.

Carter Brainerd
  • 199
  • 2
  • 10
2

After checking IDEA global settings I've found solution:

https://www.dropbox.com/s/26mz2d2mbir1r2j/Screen%20Shot%202016-09-01%20at%209.56.37%20PM.png?dl=0

Preferences -> Build, Execution, Deployment -> Gradle -> Gradle JVM -> Set to 1.8 and this works!

1

Make sure you have correct versions defined under: File -> Project Structure -> Project -> Project SDK -> Project Language Level (this is for mac, but I think you can find it for windows using the same logic).

Deniss M.
  • 3,617
  • 17
  • 52
  • 100