我无法在Mac OS上启动我的Android Studio进行Android开发(10.10.1 - Yosemite)


当前回答

对于那些在创建启动时启动的脚本时遇到困难的人,作为替代方案,你可以将这个.plist添加到你的LaunchAgents文件夹中。这可能是向系统中添加环境变量的更合适的方式,因为Yosemite决定取消launchd.conf。由于LaunchAgents文件夹的性质,这应该也适用于用户帐户,但我还没有测试。

要做到这一点,创建一个.plist文件,具有以下名称和路径:

/Library/LaunchAgents/setenv.STUDIO_JDK.plist

内容:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
            <string>setenv.STUDIO_JDK</string>
        <key>ProgramArguments</key>
            <array>
                <string>sh</string>
                <string>-c</string>
                <string>
                    launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
                </string>
            </array>
        <key>RunAtLoad</key>
            <true/>
        <key>ServiceIPC</key>
            <false/>
        <key>LaunchOnlyOnce</key>
            <true/>
        <key>KeepAlive</key>
            <false/>
    </dict>
</plist>

然后在终端中执行以下命令更改文件属性:

sudo chmod 644 /Library/LaunchAgents/setenv.STUDIO_JDK.plist

sudo chown root /Library/LaunchAgents/setenv.STUDIO_JDK.plist

sudo chgrp wheel /Library/LaunchAgents/setenv.STUDIO_JDK.plist

注:

1)您可能需要更改'jdk1.8.0_25。Jdk '以匹配您的计算机上的版本。

2)我尝试使用“jdk1.8.*”。jdk”来尝试和解释不同的Java *版本,但当我打开Android Studio时,我得到了no JVM错误,即使你运行“echo $STUDIO_JDK”它返回正确的路径。也许有人对如何解决这个问题有一些见解。

其他回答

不要编辑plist。这些说明在我几个月前第一次安装Android Studio时起了作用,就在今天。(1/21/2015)

你所需要做的只是几件简单的事情,尽管谷歌的网站上并没有列出。

First you need Java installed. this is not the JDK, it is seperate. You can get that from this link. If you don't have this it will probably throw an error saying something like "no JVM installed." Second you need the Java JDK, I got JDK 7 from this link. Make sure to choose the Mac OS X link under the Java SE Development Kit 7u75 heading. If you don't have this it will probably throw an error saying something like "no JDK installed." If you haven't already installed Android Studio, do that. But I'm sure you've already done that by now.

(更新) 这在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,看这里

尝试从Apple Support Page: http://support.apple.com/kb/DL1572下载Java,如果这对你来说不起作用或无法加载(非常常见的问题),只需按照这个链接下载并安装你需要的Java版本:

http://support.apple.com/downloads/DL1572/en_US/JavaForOSX2014-001.dmg

就是这样。

我也使用Mac OS X 10.10。为了解决这个问题。

打开Android Studio应用程序包内容(右键单击应用程序文件夹中的Android Studio图标) 打开文件info .plist 搜索和替换: <key> JVM版本号</key> . /key> . /key> . /key> . /key> <字符串> 1.6 * < /字符串>

取而代之的是:

    <key> JVM version</key>
    <string>1.6+</string>

就是这样!

在Mac OS X Yosemite上只需安装:

Java SE开发工具包8

and

Java Version 8 Update 25

都是,为我工作!