5

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

From my research, it seems this could have more to do with my operating system (OSX El Capitan) than with Gradle itself. However, I have attempted several workarounds with no success.

My studio.vmoptions file looks like this:

# 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've tried increasing my max user processes to no avail. Is anyone else having this issue? My current JDK is 1.8.0_102

2
  • Set maxheap true in menifest. Commented Sep 20, 2016 at 17:06
  • @Bansal I believe that's to enable the application to use a larger heap, but my problem happens way before I can even compile my app. My error happens during the Gradle sync in the IDE. Commented Sep 20, 2016 at 17:14

3 Answers 3

7

I have the same issue with my project which can be built without problem before upgrading.

Switched back to gradle 2.1.3 from 2.2.0 fixed the problem.

buildscript {
    ...
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.3'
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Unfortunately, it seems to be a problem with Gradle 2.1.4. There's currentlly a thread on the AOSP issue tracker. code.google.com/p/android/issues/…
0

In case someone runs into the same wall I did, you may try disabling Instant Run. I had to take these steps to build successfully: - upgrade to gradle 2.2.3 when prompted - disable Instant Run in AS preferences - go back to gradle 2.1.3 in build.gradle

Comments

0

go back to gradle 2.1.3 in build.gradle file.

1 Comment

Your answer does not provide additional info compared to the accepted answer. Please consider improving it or removing it. As it is, it will possibly get removed by revision queues. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.