Android Studio 2.2, Gradle build failed using java.lang.OutOfMemoryError: unable to create new native thread

I just upgraded to Android Studio 2.2 and I can no longer create my project because the Gradle build always fails with several java.lang.OutOfMemoryError: unable to create new native thread

From my research, it seems that this may be more related to my operating system (OSX El Capitan) than to Gradle itself. However, I tried several workarounds without success.

My studio.vmoptions file is as follows:

 # custom Android Studio VM options, see http://tools.android.com/tech-docs/configuration -Xms128m -Xmx750m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=96m -XX:+UseCompressedOops -XX:+HeapDumpOnOutOfMemoryError 

ulimit -a gives me the following:

 core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files (-n) 256 pipe size (512 bytes, -p) 1 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 709 virtual memory (kbytes, -v) unlimited 

I tried increasing my maximum user processes to no avail. Does anyone else have this problem? My current JDK is 1.8.0_102

+5
source share
3 answers

I have the same problem with my project that you can create without problems before upgrading.

Switch to gradle 2.1.3 from version 2.2.0, fixed the problem.

 buildscript { ... dependencies { classpath 'com.android.tools.build:gradle:2.1.3' } } 
+7
source

If someone runs into the same wall as me, you can try disabling Instant Run. I had to take the following steps: - upgrade to gradle 2.2.3 when prompted - disable Instant Run in AS settings - go back to gradle 2.1.3 in build.gradle

0
source

go back to gradle 2.1.3 in the build.gradle file.

0
source

All Articles