简体   繁体   中英

Android Studio - Unrecognized VM option 'MaxPermSize=256m'

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:

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.html Please 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.

I read this and 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:

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"

I'm not sure whether it's related to the error or not. Please help.

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.

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:

  • studio.vmoptions
  • studio64.vmoptions

Open these files and locate line with MaxPerSize parameter. It should look as follows:

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.

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.

EDIT :

There is another solution for this problem described here: https://stackoverflow.com/a/27913562/1150795 .

Go to File > Other Settings > Default Project Structure > JDK location and check the path.

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.

In my case opening $ANDROID_HOME/tools/lib/monitor-x86_64/monitor.ini and removing

XX:MaxPermSize=256m

from it did the job.

i had the same issue and i was able to solve it by adding this directly in the terminal

export JAVA_VERSION=1.8

and then try the

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.

On MacOS the following clause in ./gradlew injects this option:

# 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.

In my case I had a line

org.gradle.jvmargs=-Xmx6408m -XX:MaxPermSize=6408m -XX:+HeapDumpOnOutOfMemoryError

in my gradle.properties file in the project structure.

removing -XX:MaxPermSize=6408m from that file fixed an issue

-XX:MaxPermSize was deprecated in JDK 8, marked as obsolete in JDK 16, and removed in JDK 17. It was superseded by the -XX:MaxMetaspaceSize option.

Change -XX:MaxPermSize to -XX:MaxMetaspaceSize solve my problem.

ref:

  1. https://github.com/expo/expo-cli/issues/4196#issuecomment-1035850918
  2. https://docs.oracle.com/en/java/javase/17/docs/specs/man/java.html#removed-java-options

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM