Gradle不构建:app:mergeDebugResources失败

FTM*_*FTM 2 heap android build heap-memory gradle

我最近开始了一个新的Android应用程序,我得到了这个非常恼人的错误,这使我无法构建项目.

Information:Gradle tasks [clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugUnitTestSources, :app:compileDebugAndroidTestSources]
Observed package id 'add-ons;addon-google_apis-google-23' in inconsistent location 'C:\Users\Fabio\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23-1' (Expected 'C:\Users\Fabio\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23')
Already observed package id 'add-ons;addon-google_apis-google-23' in 'C:\Users\Fabio\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23'. Skipping duplicate at 'C:\Users\Fabio\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23-1'
:clean UP-TO-DATE
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2400Library
:app:prepareComAndroidSupportAppcompatV72400Library
:app:prepareComAndroidSupportDesign2400Library
:app:prepareComAndroidSupportRecyclerviewV72400Library
:app:prepareComAndroidSupportSupportV42400Library
:app:prepareComAndroidSupportSupportVectorDrawable2400Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
java.lang.OutOfMemoryError: Java heap space
:app:mergeDebugResources FAILED
Error:Execution failed for task ':app:mergeDebugResources'.
> java.lang.OutOfMemoryError: Java heap space
radle.properties file.
For example, 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>
Information:BUILD FAILED
Information:Total time: 9.513 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
Run Code Online (Sandbox Code Playgroud)

问题似乎出现在构建的这一部分中:

:app:mergeDebugResources
java.lang.OutOfMemoryError: Java heap space
:app:mergeDebugResources FAILED
Error:Execution failed for task ':app:mergeDebugResources'.
> java.lang.OutOfMemoryError: Java heap space
Run Code Online (Sandbox Code Playgroud)

我刚开始这个应用程序.它只有两个活动和4个显示.尽管有一些字符串和图像,几乎没有资源.为什么我会遇到堆内存问题?难道是因为我同时打开了2个android工作室项目吗?

我正在使用:-Gradle版本2.10 -Android插件版本2.1.2

我已经运行了"清理项目","重建项目","使用gradle文件同步项目".它没有帮助.

提前感谢您的帮助!

Aks*_*hay 5

我认为这是您的资源问题.查看您在drawable中使用的图像的大小.减小图像的大小和分辨率,然后重建项目.

  • 伙计,你是最棒的!这就是原因.我有一个svg文件,我转换为xml,我没有意识到它有20000dp的宽度和巨大的高度.我把它调整到正常大小,现在正常建立!谢谢! (4认同)