Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 233
Caesium95 Avatar asked Jul 14 '15 16:07

Caesium95


2 Answers

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

like image 179
Phate P Avatar answered Oct 23 '22 15:10

Phate P


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.

like image 14
Piotr Wittchen Avatar answered Oct 23 '22 15:10

Piotr Wittchen