Android Studio的JVM编译选项-XX:MaxPermSize高版本JDK抛错
错误日志如下:
-----------------------
Unrecognized VM option 'MaxPermSize=4096m'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.-----------------------
Check the JVM arguments defined for the gradle process in:
- gradle.properties in project root directory
原因是Java VM option的MaxPermSize选项,存在于Java 11 ~ Java 17,在Java 17以后的新/高版Java,MaxPermSize不再支持且被删除。详情见 The java Commandhttps://docs.oracle.com/en/java/javase/17/docs/specs/man/java.html#removed-java-options
-XX:MaxPermSize=
sizeSets the maximum permanent generation space size (in bytes). This option was deprecated in JDK 8 and superseded by the
-XX:MaxMetaspaceSize
option.
-XX:PermSize=
sizeSets the space (in bytes) allocated to the permanent generation that triggers a garbage collection if it's exceeded. This option was deprecated in JDK 8 and superseded by the
-XX:MetaspaceSize
option.
因此,Java 17之后,不要在Android Studio的gradle.properties配置MaxPermSize选项。
如果仍要配置这一项,请用:
-XX:MaxMetaspaceSize
替代。