1 year ago

#327086

test-img

Phoenix

R8 is causing Gradle Daemon to vanish on Github Hosted Action Runner

I am having issues with Githubs action runners while trying to compile the release version of my app. My app has 8 different flavors that we build and provide on the play store, and a few months ago I was able to build up to 3 of those flavors at the same time on one runner using Github Actions. If we tried to do more than 3 flavors at a time, after about 15 minutes, the build would fail saying

FAILURE: Build failed with an exception.

* What went wrong:

Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

and the Gradle log does not really help, besides pointing to which task was running at the time (minify r8)

When I inherited this code base, I saw that we have the max heap size in the jvm args set to 6 gigs, and if I lower that at all, I end up with out of memory errors when r8 runs. It seems kinda crazy to me that r8 would be taking that much memory, and on top of that, the github hosted runners only have 7 Gb of ram available for usage anyway. So if we combine what r8 is using in the gradle daemon, with knowing that the kotlin daemon is also running, I think the runner is killing off the gradle daemon for its memory usage or it is dying from lack of memory.

Ever since we added the Jetpack Compose Libraries, we now can't build more than one flavor of the app at a time, and I am worried about losing the ability to build on github runners due to the memory footprint r8 is causing.

This is what my current gradle.properties looks like:

org.gradle.jvmargs=-Xms1024m -Xmx6144m -XX:-UseGCOverheadLimit -XX:+HeapDumpOnOutOfMemoryError -XX:MaxPermSize=512m -XX:+UseParallelGC org.gradle.parallel=true org.gradle.configureondemand=true org.gradle.daemon=true org.gradle.caching=true android.useAndroidX=true android.debug.obsoleteApi=true kapt.incremental.apt=true

I have tried a few things to lower the workload for r8:

  1. Removed all unused resources that had managed to clutter up our resource folder
  2. We weren't actually using databinding but had both the kotlin android extensions and databinding turned on, so I turned that off
  3. We had Jetifier turned on when we didn't actually need it anymore, so I have disabled that
  4. I changed to using the parallel garbage collector
  5. I have attempted to not actually used the gradle daemon and saw no difference

With all of these changes I have seen that the overall footprint during the r8 step actually did drop to just over 5 gigs during that step, but when running on actions, if I try to do more than one flavor at a time, the daemon will still vanish.

I have spent a lot of time trying to find more info on this online, and all I can seem to find is people saying to increase the max heap size, but that will not help when my memory is limited by the machine it is running on.

I am kinda running out of ideas of what could be causing this, any help is appreciated!

android

gradle

android-gradle-plugin

android-jetpack-compose

android-r8

0 Answers

Your Answer

Accepted video resources