Android Studio报错,Error:Buildtools 24.0.1 requires Java 1.8 or above. Current JDK version is 1.7.

问题描述

Android Studio构建项目报错

Error:Buildtools 24.0.1 requires Java 1.8 or above. Current JDK version is 1.7.

检查java版本

java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
问题解决

在Project Structure设置JDK

Project Structure ->SDK Location ->JDK location 

jdk location设置为jdk8坐在的目录

gradle配置

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }