Java Android Studio 需要 JDK 7 for Android-L mac

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24472020/
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-14 12:24:14  来源:igfitidea点击:

Android Studio needs JDK 7 for Android-L mac

javaandroidmacosandroid-studio

提问by Rasalas

I was trying to look how my app looks in material design and I would like to use the new cards lib. My Problem is, that it's giving me this error within my gradle file and I need to fix that.

我试图看看我的应用程序在材料设计中的外观,我想使用新的卡片库。我的问题是,它在我的 gradle 文件中给了我这个错误,我需要解决这个问题。

Error:compileSdkVersion android-L requires compiling with JDK 7

I downloaded jdk-7u60-macosx-x64.dmgand installed it. java -versionin Terminal is showing me that 1.7 is installed:

我下载jdk-7u60-macosx-x64.dmg并安装了它。java -version在终端中显示已安装 1.7:

java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

well

ls -l `which java`

is giving me:

正在给我:

/usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

.../current/...doesn't have a .../home. I found the .../homehere:

.../current/...没有.../home. 我在.../home这里找到了:

/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home

And set the path to the "SDK location" Preferences in Android Studio under "JDK location". But it's not working -- it seems that it still can't find JDK 7.

并将路径设置为Android Studio 中“JDK 位置”下的“SDK 位置”首选项。但它不起作用——它似乎仍然找不到 JDK 7。

I'm using Mac OSX 10.9.3 and Android Studio (Beta) 0.8.1.

我使用的是 Mac OSX 10.9.3 和 Android Studio (Beta) 0.8.1。

采纳答案by megapoff

Setting the directory to: /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Homein JDK settings solved my issue. I had the same problem getting started up. Hope this helps!

将目录设置为: /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home在 JDK 设置中解决了我的问题。我在启动时遇到了同样的问题。希望这可以帮助!

回答by Erik Nedwidek

I haven't moved over to Android Studio, yet. I've used it for a few tests and really like it. Just haven't been able to switch over yet. I've had this sort of issue in Eclipse and that's obviously a different solution, but looking through one of my test projects, this appears to be how you go about it:

我还没有转移到 Android Studio。我已经将它用于一些测试并且非常喜欢它。只是还不能切换。我在 Eclipse 中遇到过这种问题,这显然是一个不同的解决方案,但是查看我的一个测试项目,这似乎是您的处理方式:

Open your project and go to File->Settings.

打开您的项目并转到文件->设置。

Under the Project Settings, expand Compiler and go to the Java Compiler option. You want to use javac and set the project bytecode version to 1.7.

在 Project Settings 下,展开 Compiler 并转到 Java Compiler 选项。您想使用 javac 并将项目字节码版本设置为 1.7。

Hopefully that'll do it.

希望那样做。

回答by nitesh goel

@megapoff answer is correct . But I face little difficulty to fix it . So here is the detail solution step-by-step

@megapoff 答案是正确的。但是我很难修复它。所以这是一步一步的详细解决方案

For Mac

对于 Mac

  1. Download the DMG file of JDK-7 from here
  2. Click on DMG and follow the instructions . It will install and configure JDK-7 on mac .
  3. Now in your android studio go to File->Project Structure -> SDK Location .
  4. In JDK locationclick on browse and go to /->Library->Java->JavaVirtualMachines->jdk1.7.0_60.jdk->Contents->Home

    Note :- Its Not /System/Libraryit's /Library

  5. click Apply and OK .... Bingo ..... Build the project again .....

  1. 从这里下载 JDK-7 的 DMG 文件
  2. 单击 DMG 并按照说明进行操作。它将在 mac 上安装和配置 JDK-7。
  3. 现在在您的 android studio 中转到 File->Project Structure -> SDK Location 。
  4. JDK 位置单击浏览并转到/->Library->Java->JavaVirtualMachines->jdk1.7.0_60.jdk->Contents->Home

    注: -它不是/System/Library/Library

  5. 单击应用和确定 .... Bingo ..... 再次构建项目 .....

回答by user3144836

The other answers are very correct but I want to be more concise and clear. To prevent others from visiting this page multiple times unnecessarily.

其他答案非常正确,但我想更简洁明了。防止他人不必要地多次访问此页面。

Important* Old Path is /System/Library/Java... and New Path is /Library/Java... (Not under the System directory)

重要* 旧路径是 /System/Library/Java... 而新路径是 /Library/Java...(不在系统目录下)

Replace old path: /System/Library/Java/JavaVirtualMachines/jdk1.6.0_0.jdk/Contents/Home

替换旧路径:/System/Library/Java/JavaVirtualMachines/jdk1.6.0_0.jdk/Contents/Home

Set your new path: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home

设置新路径:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home

回答by Asad Iftikhar

For jdk-7u79-macosx-x64.dmg just Setting the directory to /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home

对于 jdk-7u79-macosx-x64.dmg 只需将目录设置为 /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home

Not in /System/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home

不在 /System/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home

Both are different

两者都不一样

回答by Jorgesys

Instead of looking for the folder inside : /System/Library/Java/JavaVirtualMachines/

而不是寻找里面的文件夹: /System/Library/Java/JavaVirtualMachines/

enter image description here

在此处输入图片说明

We have to look into :

我们必须调查:

/Library/Java/JavaVirtualMachines/

/Library/Java/JavaVirtualMachines/

enter image description here

在此处输入图片说明