Android Studio:Buildtools 24.0.1 需要 Java 1.8 或更高版本。

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39116095/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 20:53:16  来源:igfitidea点击:

Android Studio: Buildtools 24.0.1 requires Java 1.8 or above.

javaandroidmacosandroid-studio

提问by lang2

I'm trying to setup an Android dev environment on Mac.

我正在尝试在 Mac 上设置 Android 开发环境。

My starting point is Java 1.7 I believe. So I installed android studio and opened the project I'd like to build. And it says:

我相信我的起点是 Java 1.7。所以我安装了android studio并打开了我想要构建的项目。它说:

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

So I went and download Java 1.8 u101 and installed that. No luck. Then I removed Android Studio and re-installed it and re-installed the SDK and still no luck.

所以我去下载 Java 1.8 u101 并安装它。没运气。然后我删除了 Android Studio 并重新安装了它并重新安装了 SDK,但仍然没有运气。

My Java Control Pannel says: Java 8 update 101. Output of /usr/bin/java:

我的 Java 控制面板显示:Java 8 更新 101。输出/usr/bin/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)

Output of /usr/bin/javac

输出 /usr/bin/javac

javac 1.8.0_101

What have I done wrong?

我做错了什么?

采纳答案by IntelliJ Amiya

Make sure your JDK Version through Project Structure

通过项目结构确保您的JDK 版本

enter image description here

在此处输入图片说明

You can add this in your gradle section

你可以在你的gradle部分添加这个

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

回答by C89-HD

Click project structure -> app -> in properties change the (compile Sdk Version ) to google API's 23. and in build tools Version = 22.0.1

单击项目结构 -> 应用程序 -> 在属性中将(编译 Sdk 版本)更改为 google API 的 23。并在构建工具版本 = 22.0.1

回答by P. Medas

On a Mac just double-click on the app and a new modal windows will show. Then select 'Open Module Setting'and go to 'SDK Location'.

在 Mac 上,只需双击该应用程序,就会显示一个新的模态窗口。然后选择“打开模块设置”并转到“SDK位置”