Android Studio - Gradle构建失败 - Java堆空间 [英] Android Studio - Gradle build failing - Java Heap Space

查看:166
本文介绍了Android Studio - Gradle构建失败 - Java堆空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android Studio 2.2.3。我一直在为我的当前项目构建一个android版APK,直到最近才成功。据我所知,除了数据文件外没有任何变化,并且我的Build APK步骤在gradle控制台中神秘地开始失败:

 失败:生成失败并出现异常。 
*出错:
执行任务'失败':VrSamples:Native:myproject:Projects:Android:packageDebug'。
> Java堆空间

在我的消息窗口中,我看到这个错误:

 错误:任务执行失败':VrSamples:Native:myproject:Projects:Android:packageDebug'。 
> Java堆空间
mple,gradle.properties文件中的以下行将最大Java堆大小设置为1,024 MB:
< em> org.gradle.jvmargs = -Xmx1024m< / em>
< a href =http://www.gradle.org/docs/current/userguide/build_environment.html>阅读Gradle的配置指南< / a>< br>< a href = http://docs.oracle.com/javase/7/docs/technotes/guides/vm/gc-ergonomics.html\">阅读Java的堆大小< / a>

我尝试了很多东西:


  • 将版本控制重置为先前版本我知道正在生成APK的罚款

  • 将整个项目重新克隆到新位置,以排除和交互可能存在的文件重新启动我的电脑
  • 重新安装android studio $ b $ b
  • 运行clean步骤,重建,手动删除中间文件
  • 将org.gradle.jvmargs = -Xmx1024m添加到我的gradle.properties文件中

  • 将1024m增加到4096m

  • 手动增加了Android Studio \ bin\studio.exe.vmoptions和64位等效的
  • $ b中的-Xmx值$ b


我为什么现在突然遇到这个问题感到困惑,为什么我似乎无法重新创建APK的I直到最近一直没有问题。据我所知,我也没有更新任何库。



希望有任何解决此问题的建议,关于如何调试这类事情的提示,等等。

这让我走了另一个谷歌搜索Android Studio gradle.properties未使用的属性的路径,我发现这一点:

gradle.properties。未使用的财产



与此:



问题是,至少对我来说,Windows + Android Studio似乎忽略了我项目中的gradle.properties文件。您需要在此处创建一个:
C:\ Users \.gradle \gradle.properties

然后,如其他线程其中一个通过@Kevin Tan链接到上面,我能够通过添加一行来增加内存:

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

现在我不再击中问题

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 file, and my "Build APK" step mysteriously started failing with this message in the gradle console:

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':VrSamples:Native:myproject:Projects:Android:packageDebug'.
> Java heap space

and in my "messages" window I see this error:

Error:Execution failed for task ':VrSamples:Native:myproject:Projects:Android:packageDebug'.
> Java heap space
mple, the following line, in the gradle.properties file, sets the maximum Java heap size to 1,024 MB:
<em>org.gradle.jvmargs=-Xmx1024m</em>
<a href="http://www.gradle.org/docs/current/userguide/build_environment.html">Read Gradle's configuration guide</a><br><a href="http://docs.oracle.com/javase/7/docs/technotes/guides/vm/gc-ergonomics.html">Read about Java's heap size</a>

I've tried many things:

  • Reset version control to previous version I know was generating APK's fine
  • Re-clone the entire project in a new location to rule out and intermetiate files that might be pulled in with the .gitignore, to guarantee it's a fresh build
  • Rebooted my computer
  • re-installed android studio
  • Run the clean step, rebuilt, manually deleted intermediate files
  • Added org.gradle.jvmargs=-Xmx1024m to my gradle.properties file
  • increased the 1024m to 4096m
  • manually increased the -Xmx value in both Android Studio\bin\studio.exe.vmoptions and the 64-bit equivalent

I'm puzzled as to why I'm suddenly hitting this issue now, and why I can't seem to be able to re-create the APK's I've been building without problems until recently. As far as I'm aware, I also haven't updated any libraries either.

Would appreciate any suggestions to resolve this issue, tips on how to debug this kind of thing down the road, etc.

解决方案

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\.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

这篇关于Android Studio - Gradle构建失败 - Java堆空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆