Search Unity

Gradle build fails only when building many assets using 'BuildPipeline.BuildPlayer'

Discussion in 'Android' started by ScionOfDesign, May 2, 2021.

  1. ScionOfDesign

    ScionOfDesign

    Joined:
    Oct 6, 2016
    Posts:
    82
    I have a Unity project I build via the command line using 'BuildPipeline.BuildPlayer', specifically as part of my CI solution, and I have run into a frustrating error when attempting to build the Android version of my project this way.

    What makes this frustrating is that when I manually build the project from within the editor, it builds just fine. This is with Unity version 2021.1.5f1.

    I have attached the 3 errors that I get when attempting to build via 'BuildPipeline.BuildPlayer'.
    The relevant errors as far as I can tell are as follows:
    Code (shell):
    1. WARNING: The option 'android.enableR8' is deprecated and should not be used anymore.
    2. It will be removed in a future version of the Android Gradle plugin, and will no longer allow you to disable R8.
    3. ...
    4. > Task :launcher:mergeDexRelease
    5. > Task :launcher:packageRelease
    6. > Task :launcher:packageRelease FAILED
    7.  
    Code (shell):
    1.  
    2. FAILURE: Build failed with an exception.
    3. * What went wrong:
    4. Execution failed for task ':launcher:packageRelease'.
    5. > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    6.    > value (4392877980) > 0x00000000ffffffffL
    7.  
    Code (shell):
    1. CommandInvokationFailure: Gradle build failed.
    2. C:\Program Files\Unity\Hub\Editor\2021.1.5f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2021.1.5f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.6.4.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
    3.  
    4. stderr[
    5. Note: C:\Users\Administrator\Desktop\TestBuild\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
    6. Note: Recompile with -Xlint:deprecation for details.
    7.  
    8. FAILURE: Build failed with an exception.
    9.  
    10. * What went wrong:
    11. Execution failed for task ':launcher:packageRelease'.
    12. > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    13.    > value (4392877980) > 0x00000000ffffffffL
    The project uses AddressableAssets and has many sprites. For this reason, I thought it may be this bug reported here. However, I do not see more than 680 assets in my StreamingAssets folder. Although AddressableAssets could be deleting them after it is finished. Unfortunately, the suggested workaround in the comments did not work.

    I have tried building on a clean machine with a clean install and even tried moving the assets over to a new project. The code-only builds fine, but it breaks when I add all the assets. I have tried some suggested Gradle options for similar issues, but those didn't seem to have any noticeable effect.

    Any advice on if this is a known Unity bug or if there's a workaround would be appreciated.
     

    Attached Files:

  2. ScionOfDesign

    ScionOfDesign

    Joined:
    Oct 6, 2016
    Posts:
    82
    Has anyone experienced the same issue, or does anyone have an update on this?
    It really breaks our CI pipeline.
     
  3. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
    Try exporting gradle project instead and inspect gradle.properties, see how many entries there are for unityStreamingAssets property
     
  4. ScionOfDesign

    ScionOfDesign

    Joined:
    Oct 6, 2016
    Posts:
    82
    Thanks for the response.
    I decided to wait until 2021.1.9f1 was released, as that bug report was supposed to be fixed in that version, but I am still running into the issue.

    Do you have any other tips that I could use to help debug this issue?