Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Gradle error when compiling with big files

Discussion in 'Android' started by Jand42, Jun 30, 2023.

  1. Jand42

    Jand42

    Joined:
    Jun 30, 2023
    Posts:
    1
    Hello!

    We are having a problem to compile a project in android using Unity 2022.3.3f1. We believe that the problem is due to the fact that the project must have 5 fairly large videos (all close to 1Gb). When trying to compile we get the following error:

    "A failure occurred while executing com.android.build.gradle.internal.tasks.CompressAssetsWorkAction See the Console for details."

    In the Console:

    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    * What went wrong:
    Execution failed for task ':launcher:compressReleaseAssets'.
    > A failure occurred while executing com.android.build.gradle.internal.tasks.CompressAssetsWorkAction
    > Required array size too large


    CommandInvokationFailure: Gradle build failed.
    C:\Program Files\Unity\Hub\Editor\2022.3.3f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2022.3.3f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.2.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

    Do you know any way to solve this problem?
     
    Reflekst and DaveA_VR like this.
  2. DaveA_VR

    DaveA_VR

    Joined:
    May 26, 2022
    Posts:
    29
    Getting almost the same thing.


    * What went wrong:
    Execution failed for task ':launcher:compressDebugAssets'.
    > A failure occurred while executing com.android.build.gradle.internal.tasks.CompressAssetsWorkAction
    > Required array size too large
     
    Reflekst likes this.
  3. Reflekst

    Reflekst

    Joined:
    Apr 14, 2021
    Posts:
    1
    Hi, me too guys.
    Did you find out how to fix it?
     
  4. ibenc

    ibenc

    Joined:
    Sep 30, 2016
    Posts:
    2
    Hi all,

    I'm experiencing the same issue.
    On local builds and also on Unity Cloud build.

    It seems that gradle does not have enough memory to execute compression.
    I tried to extend the memory available to gradle but with no success, it seems the unityeditor starts the gradle without taking into account gradle.propoertries.

    Has anyone found a workaround?
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,637
    Android package files are zip files, so they are limited to 4GB in size. Gradle build will fail if you exceed that.
     
  6. ibenc

    ibenc

    Joined:
    Sep 30, 2016
    Posts:
    2
    Thanks Aurimas-Cernius, but I do not think the final size of Android package is issue here.
    Previous builds have worked fine and produced android packages of ~2,5GB.
    The problem only started manifesting after upgrading Unity 2021.3 to Unity 2022.3.
    No project files have been changed, only version of Unity editor changed.
     
  7. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,637
    If you exceed 2GB, you risk the failure. Unity upgrade probably also means android build tools update, as we update them regularly. I don't know the exact conditions when they fail, depends on exact data being packed.
    In any case, these are Google tools, we can't really do anything about it.
     
  8. Ictcmn

    Ictcmn

    Joined:
    Nov 17, 2014
    Posts:
    3
    I am having this problem as well when I tried to add scenes I had been testing individually into a complete package. So is this the answer? Just that no Meta Quest 2 game/apk is bigger than 4gb? Are there no workarounds that would enable building things separately and combining after - or running the compression task separately before building the APK?