我无法在Mac OS上启动我的Android Studio进行Android开发(10.10.1 - Yosemite)
当前回答
我运行了这个坏小子:
launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/
其他回答
编辑android工作室的信息。plist文件,以便它使用1.7或任何您已经安装的JVMVersion。将JVMVersion更改为1.6+而不是如上所述的hassternet回答的1.6*应该也可以工作。
上述工作,但不建议参阅RC3发行说明
As of RC 3, we have a better mechanism for customizing properties for the launchers on all three platforms. You should not edit any files in the IDE installation directory. Instead, you can customize the attributes by creating your own .properties or .vmoptions files in the following directories. (This has been possible on some platforms before, but it required you to copy and change the entire contents of the files. With the latest changes these properties are now additive instead such that you can set just the attributes you care about, and the rest will use the defaults from the IDE installation).
Android Studio无法在Mac OSX上加载JVM (Mavericks)
在Android工具项目网站上,有一个很好的解释Mac OSX JDK选择。它解决了我的问题。总而言之:
Android Studio需要两个不同的jdk: IDE本身使用的Java版本。 它用来获取Java编译器的JDK版本 这两者可以(而且通常是)相同,但是您可以进行配置 他们单独。尤其是在OSX上,它们经常是这样的 不同。
Yosemite (Mac OSX 10.10)
首先,请确保您拥有最新版本的Java 6 安装;在某些情况下,这已经解决了问题: http://support.apple.com/kb/DL1572 如果不是,请尝试运行最新版本的Java 7或Java 8 如上所述设置STUDIO_JDK。据报道,这个问题已经解决 其他问题(尽管您将得到字体渲染显示 Java 8以上。)
在finder中打开Android Studio的应用程序包,并编辑信息。plist文件。修改密钥JVMversion。用1.6+代替1.6*。这招对我很管用!
编辑:
虽然这在旧版本的Android Studio中是必要的,但不再推荐这样做。详见官方声明
"请注意:不要编辑信息。请选择一个不同的版本。这不仅会破坏应用程序的签名,还会破坏未来的补丁更新。”
安东尼奥•何塞的答案是正确的。
谢谢aried3r !
您可以使用用户的启动代理来实现STUDIO_JDK解决方案。这涉及到在您的LaunchAgents目录中创建一个plist文件,位于~/Library/LaunchAgents
创建一个新文件~/Library/LaunchAgents/UNIQUE_KEY。其中UNIQUE_KEY只是一个标识符。我使用com.username.androidstudio。
将以下文本复制到新的plist文件中,并根据下面的说明修改它。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>UNIQUE_KEY</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
你需要做两个修改:
更改UNIQUE_KEY以匹配您的文件名(不带.plist扩展名)。 验证您的JDK路径是否正确,并在必要时进行更改。在本例中,我使用7u71。
这和安东尼奥·何塞的答案是一样的。它根据Android Studio版本1.0 RC3发布说明设置STUDIO_JDK环境变量。这个解决方案使用LaunchAgents目录而不是AppleScript来设置环境变量。因此,这主要是您如何安排和组织系统和环境变量的差异。
(更新) 这在Android Studio 1.1中得到了修复 https://issuetracker.google.com/issues/37015035
在下一个版本的Android Studio中,如果没有找到java 6,但找到了java 7(或更高),那么它将使用java 6。我们仍然推荐使用Java 6运行studio,因为它改进了字体渲染,但是如果只找到Java 8,就不需要做任何工作。
(最后更新)
从Android Studio 1.0 RC3 Notes
As of RC 3, we have a better mechanism for customizing properties for the launchers on all three platforms. You should not edit any files in the IDE installation directory. Instead, you can customize the attributes by creating your own .properties or .vmoptions files in the following directories. (This has been possible on some platforms before, but it required you to copy and change the entire contents of the files. With the latest changes these properties are now additive instead such that you can set just the attributes you care about, and the rest will use the defaults from the IDE installation).
然而,没有解释什么是选项。
找了一会儿,我找到了这个 在Mac上调整Android Studio的虚拟机选项 IntelliJ IDEA 14.0.0 Web帮助/文件IDEA。属性
然而,运气不佳。
幸运的是,我能够像1.0 RC3发行说明中所说的那样,使用环境变量在优胜美地解决这个问题。
你也可以把使用环境变量放在其他地方指向特定的覆盖文件: STUDIO_VM_OPTIONS,使用哪个vmoptions文件 STUDIO_PROPERTIES,使用哪个属性文件 STUDIO_JDK,用于运行studio的JDK
这有点棘手,因为Android Studio不是一个命令行应用程序,所以我必须使用AppleScript命令来设置登录时的环境变量。更多信息请点击这里
这是命令行的launchctl命令。
launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
这是我的AppleScript(记得保存为应用程序)
do shell script "launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk"
关于launchctl,看这里
推荐文章
- 警告:API ' variable . getjavacompile()'已过时,已被' variable . getjavacompileprovider()'取代
- 安装APK时出现错误
- 在流中使用Java 8 foreach循环移动到下一项
- 访问限制:'Application'类型不是API(必需库rt.jar的限制)
- 用Java计算两个日期之间的天数
- 为什么在Mac OS X v10.9 (Mavericks)的终端中apt-get功能不起作用?
- 碎片中的onCreateOptionsMenu
- 如何配置slf4j-simple
- 在Jar文件中运行类
- 带参数的可运行?
- TextView粗体通过XML文件?
- 如何使线性布局的孩子之间的空间?
- 我如何得到一个字符串的前n个字符而不检查大小或出界?
- 我可以在Java中设置enum起始值吗?
- Java中的回调函数