After several hours of fighting to get an older project imported from Eclipse to use Gradle and into Android Studio v0.1.3...what I've gotten to now is I can actually do the build on the command line, but when I do Build/Rebuild Project in Studio I get:
Gradle:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':EpicMix'.
> Failed to notify project evaluation listener.
> A problem occurred configuring project ':facebook'.
> Failed to notify project evaluation listener.
> java.lang.OutOfMemoryError: PermGen space
It's not a HUGE project, there's a few small sub-projects (including Facebook), so I don't think it really is memory. I just can't figure out what this is...
For those of you running gradle from the command line, create a gradle.properties file, put it in the root of your project, and add the following:
org.gradle.jvmargs=-XX:MaxPermSize=512m
The size of the PermGen space can be increased within Android Studio under File > Settings > Compiler. Look for the setting named "Additional compiler process VM options". Just add the following parameter:
-XX:MaxPermSize=512M
The default value is 92M. Use G if you want to specify a value in gigabytes.
If you are on Mac OS X it's possible to increase MaxPermSize inside file
/Applications/Android Studio.app/bin/idea.vmoptions
The recommended way of setting JVM arguments, such as max PermGen size, is by following the advice given here - http://tools.android.com/tech-docs/configuration
Android Studio 2.0 and newer
As of Android Studio 2.0, there is an option to access the configuration file directly from the IDE.
Use the Help->Edit Custom VM Options
menu.
Taken from the configuration page, the full set of JVM arguments are as follows, alongs with their default values:
-Xms128m
-Xmx750m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=96m
-XX:+UseCompressedOops
Legacy Instructions:
You should create your own studio.vmoptions file and put your JVM settings in here. The location of your file should be:
- Mac OS ~/Library/Preferences/AndroidStudio/studio.vmoptions
- Linux ~/.AndroidStudio/studio.vmoptions (or ~/.AndroidStudio/studio64.vmoptions)
- Windows: %USERPROFILE%.AndroidStudio\studio.exe.vmoptions (or %USERPROFILE%.AndroidStudio\studio64.exe.vmoptions)
Note, you should no longer edit the files in the AndroidStudio app directory as these will be overwritten with each new installation/update to the IDE.
Also, this worked for me - if you're in Linux, just set the environment variable GRADLE_OPTS to be "-XX:MaxPermSize=512m" (or whatever size you want).
Try adding this to your gradle.properties:
org.gradle.jvmargs=-XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -Dfile.encoding=utf-8
You can have a gradle.properties
file and then add the following.
Create or edit the ~/.gradle/gradle.properties
to include the following
org.gradle.daemon=false
GRADLE_OPTS="-Xmx2048m -Xms2048m -XX:MaxPermSize=1024m"
org.gradle.jvmargs=-XX:MaxPermSize=1024m
At every build or clean several java processes are started causing Out of Memory errors.
Brute force solution:
Kill java.exe processes before any build or run. This will have side effects on any other active application working with java.
[Android Studio 1.4 - JRE 1.7.0_75-b13]
On a Mac go to ~/.gradle and delete both the caches and daemon folders. These get regenerated.
In your Gradle build file add the following jvmArgs inside test {} block to increase the perm-gen space allocation:
test {
jvmArgs "-XX:MaxPermSize=1024m"
}