After update to use Android Gradle Plugin 3.6.1 from 3.5.3, our unit test keeps getting OutOfMemoryError exception randomly.
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. 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
So far, what I have tried are:
Try to play with some gradle flags. But so far, there is no luck.
Play around with some testOptions flags ( https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html ), for example 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.
My setup:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.