Search Issue Tracker

Fixed in Unity 2018.3

Votes

72

Found in

2017.3.0b1

Issue ID

969563

Regression

Yes

[Android] Gradle build fails when building project with asset bundle

Android

-

-

Priority: 2Necessary for shipping a final release

-

Severity: 2Core functionality majorly impacted

Reproduction steps:
1. Open the attached project
2. The project has 1 asset bundle. The bug isn't reproducible using other asset bundles or even the same bundle but using different compression
3. Try to build for Android using Gradle
4. Fails with following output:

CommandInvokationFailure: Gradle build failed.
C:/Program Files/Java/jdk1.8.0_111\bin\java.exe -Xmx1024M -classpath "C:\Program Files\Unity 2017.3.0b1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.0.1.jar" org.gradle.launcher.GradleMain "--no-daemon" "assembleDebug"

stderr[

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':packageDebug'.
> Java heap space

and following error window:
https://gyazo.com/6443561e02dd58fc7dff970cd477c218

Regression introduced in 2017.3.0b1

Reproducible in:
2019.1.0a6, 2018.3.0b1, 2018.3.0a6

Environment:
Windows 10 and Mac 10.13

Comments (39)

  1. Edda78c780f00da9ec3fd47f766d20b1?d=mm

    vthera_trond

    Dec 12, 2018 00:46

    Change logs indicate that this is fixed in 2018.2.16f1. However, we still get fails when running Unity from the command line with -Xmx1024M set when Gradle is called. In 2018.2.5f1, it gave -Xmx2048M. We're not keen to push up to 2018.3 beta, but I'm hoping its fixed there.

  2. Edda78c780f00da9ec3fd47f766d20b1?d=mm

    vthera_trond

    Dec 12, 2018 00:46

    Change logs indicate that this is fixed in 2018.2.16f1. However, we still get fails when running Unity from the command line with -Xmx1024M set when Gradle is called. In 2018.2.5f1, it gave -Xmx2048M. We're not keen to push up to 2018.3 beta, but I'm hoping its fixed there.

  3. F7fb58fa29523686f210a6224dd7f5e3?d=mm

    amaceikaCortina

    Dec 06, 2018 16:30

    Ran across this issue in 2017.3.1f1 also ran in to build errors with the latest version of Android Studio had to revert the tools folder.

  4. F7fb58fa29523686f210a6224dd7f5e3?d=mm

    amaceikaCortina

    Dec 06, 2018 16:30

    Ran across this issue in 2017.3.1f1 also ran in to build errors with the latest version of Android Studio had to revert the tools folder.

  5. F04686de922ce4516cacbe7c55189472?d=mm

    jason_pocketpinata

    Nov 15, 2018 19:23

    I was able to fix in a gradle build by setting the daemon heap memory to 4096 in gradle.properties:
    org.gradle.jvmargs=-Xmx4096M

    I cannot figure out how to get unity to set this value though in a regular unity build

  6. 10a9f3fb55363a7065c7514f787254db?d=mm

    alexeysanuk

    Oct 31, 2018 08:18

    Unity 2018.2.4, issue happened with out asset bundles, build with Gradle system.

  7. Ca257b341ceba54bef73094eb76e786f?d=mm

    multimediamarkers

    Jul 05, 2018 09:35

    Also error on Unity 2018.1.4f1 ... setting the build system to "internal" helped!

  8. 8a6f8453d5cb172d946fa7209da7d801?d=mm

    DaneyT

    Jun 18, 2018 14:30

    I may have found solution, a possible workaround.
    It requires that you have Android Studio installed.

    Steps:
    1.In the build settings window of Unity Android select: Build system: Gradle and check Export project.
    2.After exporting, open Android Studio and open your exported Unity project.
    3.Open the file: gradle.properties, here you will see a line which controls how much RAM can be used while building.
    4. Change it to: org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m (If you have more than 4GB of ram). Mine was at 1524m before, this is most likely the same problem in Unity.
    5. Build the project(green hammer) and find the .apk in the Builds-> Outputs folder or run it with your device connected.

    This allowed me to build a .apk which kept failing in Unity due to the Java Heap space error.
    I used Unity 2018.1.0f2 and Android Studio 3.1.2

  9. F52992705535ebb3050d9dd3aa73d7b5?d=mm

    mmSimon

    May 23, 2018 14:14

    We're also facing this issue in Unity 5.6.5f1 using Gradle builds. Fortunately we can still build using a Split APK/OBB build but this is making things a bit more complicated for testing.

  10. F8d03cd762f38086785515ab0fe61db4?d=mm

    jeffrobernard1

    May 15, 2018 20:44

    I'm having the same issue. Running mac High Sierra, Unity 2018.1.0of2. Had everything building fine added 2 360 videos, and now i'm getting the java heap space error. Tried a number of suggested fixes and nothing yet.
    Also running:
    mac High Sierra
    , Unity 2018.1.0of2
    Android Tools 26.0.2
    JDK jdk1.8.0_172.jdk

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.