Java Android Studio - 无法识别的 VM 选项“MaxPermSize=256m”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31411989/
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
Android Studio - Unrecognized VM option 'MaxPermSize=256m'
提问by Caesium95
I just installed Android Studio on Elementary OS 0.3 Freya and run it using the terminal. On my first start-up, however, there's an error message shown:
我刚刚在 Elementary OS 0.3 Freya 上安装了 Android Studio 并使用终端运行它。但是,在我第一次启动时,显示了一条错误消息:
Gradle 'Test' project refresh failed
Unable to start the daemon process. This problem might be caused by incorrect configuration of the daemon. For example, an unrecognized jvm option is used. Please refer to the user guide chapter on the daemon at http://gradle.org/docs/2.2.1/userguide/gradle_daemon.htmlPlease read the following process output to find out more:
Unrecognized VM option 'MaxPermSize=256m' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
Gradle“测试”项目刷新失败
无法启动守护进程。此问题可能是由守护程序的错误配置引起的。例如,使用了无法识别的 jvm 选项。请参阅http://gradle.org/docs/2.2.1/userguide/gradle_daemon.html上有关守护程序的用户指南章节, 请阅读以下进程输出以了解更多信息:
无法识别的 VM 选项“MaxPermSize=256m”错误:无法创建 Java 虚拟机。错误:发生了致命异常。程序将会退出。
I read thisand tried all the ways to solve it but to no avail. I did notice that his error was somewhat different from mine and thought that might be why I couldn't solve my problem using the ways suggested.
我读了这篇文章并尝试了所有方法来解决它,但无济于事。我确实注意到他的错误与我的有些不同,并认为这可能是我无法使用建议的方法解决我的问题的原因。
As I executed the .sh file on my terminal, it printed:
当我在终端上执行 .sh 文件时,它打印出:
Java HotSpot(TM) Server VM warning: ignoring option MaxPermSize=250m; support was removed in 8.0
(java:5094): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap"
Gtk-Message: Failed to load module "canberra-gtk-module"
Java HotSpot(TM) 服务器 VM 警告:忽略选项 MaxPermSize=250m;在 8.0 中移除了支持
(java:5094): Gtk-WARNING **: 无法在 module_path 中找到主题引擎:“pixmap”
Gtk 消息:无法加载模块“canberra-gtk-module”
I'm not sure whether it's related to the error or not. Please help.
我不确定它是否与错误有关。请帮忙。
回答by Piotr Wittchen
As it was already said in this thread, Permanent Generation was removed in Java 8, which is used in your case. I think, the easiest solution is to remove parameters associated with Permanent Generation during program execution.
正如在这个线程中已经说过的那样,在 Java 8 中删除了 Permanent Generation,在您的情况下使用了它。我认为,最简单的解决方案是在程序执行期间删除与永久代相关的参数。
Go to the directory where you have Android Studio. Then go to the bin/
subdirectory. Locate the following files, which contains Java Virtual Machine options:
转到您拥有 Android Studio 的目录。然后进入bin/
子目录。找到以下文件,其中包含 Java 虚拟机选项:
studio.vmoptions
studio64.vmoptions
studio.vmoptions
studio64.vmoptions
Open these files and locate line with MaxPerSize
parameter. It should look as follows:
打开这些文件并找到带有MaxPerSize
参数的行。它应该如下所示:
XX:MaxPermSize=256m
XX:MaxPermSize=256m
Remove this line in both files. I don't know if you are using 32-bit or 64-bit operating system, so you can update both files just in case.
删除这两个文件中的这一行。我不知道您使用的是 32 位还是 64 位操作系统,因此您可以更新这两个文件以防万一。
I'm not sure if it will solve your problem, but I would try it in such situation. In my case, with this option and Java 8, I just get the warning, but Android Studio starts anyway. After removing this parameter, Android Studio still starts, but without warning. I'm using Ubuntu 14.04 LTS.
我不确定它是否会解决您的问题,但我会在这种情况下尝试。就我而言,使用此选项和 Java 8,我只会收到警告,但无论如何 Android Studio 都会启动。去掉这个参数后,Android Studio 仍然启动,但没有警告。我正在使用 Ubuntu 14.04 LTS。
EDIT:
编辑:
There is another solution for this problem described here: https://stackoverflow.com/a/27913562/1150795.
此处描述了针对此问题的另一种解决方案:https: //stackoverflow.com/a/27913562/1150795。
Go to File > Other Settings > Default Project Structure > JDK locationand check the path.
转到文件 > 其他设置 > 默认项目结构 > JDK 位置并检查路径。
In case of Ubuntu Linux, we can set /usr/lib/jvm/java-7-oracle
as default JDK if we are using Oracle JVM. JDK 7 is the safest option for Android.
在 Ubuntu Linux 的情况下,/usr/lib/jvm/java-7-oracle
如果我们使用 Oracle JVM ,我们可以设置为默认 JDK。JDK 7 是 Android 最安全的选择。
回答by Li Hao
Oh I've solved this problem, I install Oracle JDK 9 when android studio runs on JDK 6 or JDK 7 (if I'm not mistaken). so I uninstalled Oracle JDK 9, then download and install the JDK 7.
哦,我已经解决了这个问题,当 android studio 在 JDK 6 或 JDK 7 上运行时,我安装了 Oracle JDK 9(如果我没记错的话)。所以我卸载了 Oracle JDK 9,然后下载并安装了 JDK 7。
回答by foo
In my case opening $ANDROID_HOME/tools/lib/monitor-x86_64/monitor.ini
and removing
在我的情况下打开$ANDROID_HOME/tools/lib/monitor-x86_64/monitor.ini
和删除
XX:MaxPermSize=256m
XX:MaxPermSize=256m
from it did the job.
从它做的工作。
回答by Alex Cohn
On MacOS the following clause in ./gradlewinjects this option:
在 MacOS 上,./ gradlew 中的以下子句注入了这个选项:
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\" \"-Xmx1024m\" \"-Xms256m\" \"-XX:MaxPermSize=1024m\""
fi
This file can be edited by hand after the project has been generated.
该文件可以在项目生成后手动编辑。