Android Studio - Gradle build failing - Java Heap Space

后端 未结 3 1527
日久生厌
日久生厌 2020-12-10 13:50

Android Studio 2.2.3. I\'ve been building an APK for android with my current project with success until very recently. As far as I know, nothing was changed except a data

相关标签:
3条回答
  • 2020-12-10 14:31

    I noticed that when I open the gradle.properties folder in my Android Studios project, and hovered over any line, it gave a warning about "unused property". That put me on the path to do another google search for "Android Studio gradle.properties unused property" and I found this:

    gradle.properties. Unused property

    and this:

    JVM arguments gradle cannot be set in gradle.properties file for Android Studio 2.1.1

    The issue is that, at least for me, Windows+Android Studio seems to ignore the gradle.properties file in my project. You need to create one here: C:\Users\<username>\.gradle\gradle.properties

    Then, as suggested in other threads such as the one linked to by @Kevin Tan above, I was able to increase the memory by adding a line such as this:

    org.gradle.jvmargs=-XX:MaxHeapSize=256m -Xmx256m
    

    Now I no longer hit the issue

    0 讨论(0)
  • 2020-12-10 14:43

    By default, Android Studio has a maximum heap size of 1280MB. If you are working on a large project, or your system has a lot of RAM, you can improve performance by increasing the maximum heap size for Android Studio processes, such as the core IDE, Gradle daemon, and Kotlin daemon.

    If you use a 64-bit system that has at least 5 GB of RAM, you can also adjust the heap sizes for your project manually. To do so, follow these steps:

    Click File > Settings from the menu bar (or Android Studio > Preferences on macOS). Click Appearance & Behavior > System Settings > Memory Settings.

    For more Info click

    https://developer.android.com/studio/intro/studio-config

    0 讨论(0)
  • 2020-12-10 14:44

    Use this in gradle.properties

    org.gradle.parallel=true
    org.gradle.daemon=true
    org.gradle.jvmargs=-Xmx12800M
    org.gradle.configureondemand=true
    

    Worked for me.

    0 讨论(0)
提交回复
热议问题