Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

assembleDebug runs out of memory when rebuilding all examples

已关闭
#25 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

已经有一个关联 PR 被合并了。

  • #28 来自 @afarber —— 已合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
android, kotlin
领域
build-system

调研方向

The fix is configuration, so start in gradle.properties (the org.gradle.jvmargs=-Xmx4096m heap and where worker limits would go) and check settings.gradle.kts. The failing task is mergeExtDexDebug in the example modules, such as examples:Example04Polylines. Reproduce with ./gradlew --stop then ./gradlew assembleDebug --rerun-tasks. Done means that command succeeds without --max-workers. Confirm with the maintainer which of the two proposed fixes to take, since raising the heap and capping workers trade off differently.

由索引模型根据 Issue 内容生成。

描述

bug

A full rebuild of the example apps fails with OutOfMemoryError: Java heap space in the Gradle daemon on machines with many CPU cores.

Steps to reproduce

./gradlew --stop
./gradlew assembleDebug --rerun-tasks

On a 14-core Mac this fails after about 15 seconds, usually in mergeExtDexDebug of one or more examples:

> Task :examples:Example04Polylines:mergeExtDexDebug FAILED
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Caused by: java.lang.OutOfMemoryError: Java heap space

After the failure the daemon can be left in a broken state ("Cannot lock file hash cache ... already been locked by this process"), so ./gradlew --stop is needed before the next build.

The same failure also happens without --rerun-tasks whenever all examples need to be rebuilt, for example after a change in the library or in settings.gradle.kts. Incremental builds are not affected.

Cause

All 12 example apps run dex merging in parallel inside the Gradle daemon. The number of parallel workers defaults to the number of CPU cores, but the daemon heap is limited to 4 GB (org.gradle.jvmargs=-Xmx4096m in gradle.properties). CI is not affected because its runners have fewer cores.

Limiting the workers avoids the problem:

./gradlew --stop
./gradlew assembleDebug --rerun-tasks --max-workers=4   # BUILD SUCCESSFUL

Possible fixes

  • Increase the daemon heap in gradle.properties, for example -Xmx6g
  • Or limit parallelism with org.gradle.workers.max in gradle.properties
主要语言
Kotlin
星标
4
派生
1
平均合并
1 小时 55 分钟
30 天内合并 PR
29

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。