Fixed: Invalid APK or AAB after gradle task failure

There have been two recent conditions that have caused the app-builder execution to fail but the Scriptoria build script was not catching it and still copying APK and AAB files even though they were not complete and would fail to run or upload to Google Play. These two conditions are:

  1. Using GeckoView would use too much memory when linking the binary and there would be a “Java Heap Space” error in the logs.
  2. Using too many images (verse on image, video previews) would cause the AAPT2 process which resizes the images to stop running and there would be a “Idle daemon unexpectedly exit. This should not happen.” error in the logs.

If you have these issues, I have done the following to address them:

  1. I have added code to verify the APK and AAB so that there won’t be build that say they succeeded but actually produced bad files.
  2. To temporarily work around the first issue with GeckoView, I have added support for BUILD_JAVA_MAX_HEAP_SIZE publishing property that will increase the memory used during the build of the APK or AAB file.
  3. Increased the size of the VM that is used in builds to work around the second issue. This doubles the cost of EVERY build.

There is a small percentage of projects that need the extra memory (and only for the Android build step). I will be adding a way to increase the memory used by only product builds that need it. In the mean while, if you have a project with GeckoView, then add the BUILD_JAVA_MAX_HEAP_SIZE publishing property and set to 1.

Chris Hubbard

I have the final fix for this issue that will replace the temporary work-around.

If you have a project that uses GeckoView or that fails to build due to too many images, contact the Organizational Admin who can make the following change.

In the kebob menu at the end of the product (below Details), for Organizational Admins there will be a “Publishing Properties” menu item.

This menu item will bring up a modal dialog to modify new product-specific publishing properties. On this dialog, there is a dropdown to change the Compute Type of the build.


Making a selection will populate the publishing properties needed to use a larger MV when building just the product.


The next time the product is built, it will use a larger VM with more memory given to SAB to build the project.

You no longer need the BUILD_JAVA_MAX_HEAP_SIZE and should be removed from the publishing properties in SAB.

This has gone live today (12/21/2022).

For His Great Name,
Chris Hubbard

1 Like