简体   繁体   English

运行单元测试时将 Android Gradle 插件从 3.5.3 更新到 3.6.1 后出现 OutOfMemoryError

[英]Got OutOfMemoryError after update Android Gradle Plugin to 3.6.1 from 3.5.3 when run unit test

After update to use Android Gradle Plugin 3.6.1 from 3.5.3, our unit test keeps getting OutOfMemoryError exception randomly.从 3.5.3 更新到使用 Android Gradle 插件 3.6.1 后,我们的单元测试不断随机获取 OutOfMemoryError 异常。

These are the crash logs:这些是崩溃日志:

 Caused by: com.android.ide.common.workers.WorkerExecutorException: 1 exception was raised by workers: java.lang.OutOfMemoryError at com.android.ide.common.workers.ExecutorServiceAdapter.await(ExecutorServiceAdapter.kt:108) at com.android.ide.common.workers.ExecutorServiceAdapter.close(ExecutorServiceAdapter.kt:118) at kotlin.io.CloseableKt.closeFinally(Closeable.kt:53) at com.android.build.gradle.internal.res.GenerateLibraryRFileTask.doFullTaskAction(GenerateLibraryRFileTask.kt:120) at com.android.build.gradle.internal.tasks.IncrementalTask.handleIncrementalInputs(IncrementalTask.kt:107) at com.android.build.gradle.internal.tasks.IncrementalTask.access$handleIncrementalInputs(IncrementalTask.kt:64) at com.android.build.gradle.internal.tasks.IncrementalTask$taskAction$$inlined$recordTaskAction$1.invoke(AndroidVariantTask.kt:73)

As my investigation.作为我的调查。 AGP 3.6.x changed the way to generate the R file. AGP 3.6.x 改变了生成 R 文件的方式。 And the crash happens in this line of code: https://android.googlesource.com/platform/tools/base/+/studio-master-dev/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/res/GenerateLibraryRFileTask.kt#120崩溃发生在这行代码中: https : //android.googlesource.com/platform/tools/base/+/studio-master-dev/build-system/gradle-core/src/main/java/com/ android/build/gradle/internal/res/GenerateLibraryRFileTask.kt#120

So far, what I have tried are:到目前为止,我尝试过的是:

  1. Try to play with some gradle flags.尝试使用一些 gradle 标志。 But so far, there is no luck.但到目前为止,还没有运气。

    • android.enableGradleWorkers=true/false android.enableGradleWorkers=true/false
    • kapt.use.worker.api=true/false kapt.use.worker.api=true/false
    • kotlin.parallel.tasks.in.project=true/false kotlin.parallel.tasks.in.project=true/false
    • android.useCompileClasspathLibraryRClasses=false android.useCompileClasspathLibraryRClasses=false
  2. Play around with some testOptions flags ( https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html ), for example forkEvery, maxParallelForks.使用一些 testOptions 标志( https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html ),例如 forkEvery、maxParallelForks。 But I am not sure it would help, because the failure happens on the building phrase.但我不确定它会有所帮助,因为失败发生在构建短语上。

    I am trying to get the heapdump but it's kind of difficult because the OOM happens randomly.我正在尝试获取 heapdump,但这有点困难,因为 OOM 是随机发生的。

    My setup:我的设置:

    • Gradle version: 6.2.2摇篮版本:6.2.2
    • Android Gradle Plugin: 3.6.1 Android Gradle 插件:3.6.1
    • Android SDK Build-Tools 28.0.3 And I run the unit test by the command-line tool. Android SDK Build-Tools 28.0.3 我通过命令行工具运行单元测试。 It should not be related to AS.它应该与AS无关。

It will be very appreciated if anyone of you would suggest any solution or direction to investigate如果你们中的任何人建议任何解决方案或方向进行调查,我们将不胜感激

Just for your info.仅供参考。 I have to fire an issue too google here https://issuetracker.google.com/u/1/issues/151460310我也必须在谷歌这里发一个问题https://issuetracker.google.com/u/1/issues/151460310

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用android gradle插件时,在packageApplication之后运行任务 - Run task after packageApplication when using the android gradle plugin 带有 Gradle 插件版本 3.6.1 和 Gradle 版本 5.6.4 的 Android Studio 3.6.1 不起作用 - Android Studio 3.6.1 with Gradle Plugin Version 3.6.1 and Gradle Version 5.6.4 not working 在 Android Studio 更新到 4.2 和 Gradle 更新后,我收到了这个错误 - I got this error after the Android Studio update to 4.2 and the Gradle update 从gradle运行单个Android(单元)测试,而不加载其他项目依赖项 - Run a single Android (unit) test from gradle without loading other project dependencies 更新到android gradle插件2.3后,多模块MultiDex项目不会运行测试 - Multi-module MultiDex project won't run tests after update to android gradle plugin 2.3 在 android gradle 3.6.1 中运行构建任务后未生成 Jar - Jar is not generated after running build task in android gradle 3.6.1 "更新到 Gradle 5.6.4 和 Android Studio 3.6.1 后 nativeLibraryDir 显示为空" - nativeLibraryDir appears empty after updating to Gradle 5.6.4 and Android Studio 3.6.1 OutOfMemoryError:在 android studio 3.0 中更新 gradle 插件后超出了 GC 开销限制 - OutOfMemoryError: GC overhead limit exceeded after Updating gradle plugin in android studio 3.0 只有在运行单元测试时才能运行自定义gradle任务 - Want to run a custom gradle task only when running Unit test 使用 gradle 编译我的 android 应用程序时出现 OutOfMemoryError - OutOfMemoryError when compiling my android app with gradle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM