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


当前回答

在finder中打开Android Studio的应用程序包,并编辑信息。plist文件。修改密钥JVMversion。用1.6+代替1.6*。这招对我很管用!

编辑:

虽然这在旧版本的Android Studio中是必要的,但不再推荐这样做。详见官方声明

"请注意:不要编辑信息。请选择一个不同的版本。这不仅会破坏应用程序的签名,还会破坏未来的补丁更新。”

安东尼奥•何塞的答案是正确的。

谢谢aried3r !

其他回答

“在Mac OS上,运行带有Java运行时环境(JRE) 6的Android Studio,以优化字体渲染。然后,您可以配置您的项目使用Java开发工具包(JDK) 6或JDK 7。”

这是在Mac OS X系统要求下的http://developer.android.com/sdk/index.html中列出的。

一旦你按照Alonso C. Licks从苹果安装了Java 6(而不是JDK),你应该能够打开Android Studio并重新配置,而不必在终端中混乱,信息。Plist文件或其他库。

不要编辑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.

在Info.plist中更改此键

我从

<key>JVMVersion</key>
<string>1.6*</string>

to

<key>JVMVersion</key>
<string>1.8*</string>

现在它工作得很好。

编辑: 根据hasternet和aried3r上面提到的官方声明,Antonio Jose的解决方案是正确的。

谢谢!

对于那些在创建启动时启动的脚本时遇到困难的人,作为替代方案,你可以将这个.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”它返回正确的路径。也许有人对如何解决这个问题有一些见解。

我可以通过编辑信息来让它工作。请将16*改为16+。尝试使用推荐的方法,但失败了。