Search Issue Tracker

Fixed in 2018.3.X

Fixed in 2017.4.X, 2018.2.X

Votes

72

Found in

2017.3.0b1

Issue ID

969563

Regression

Yes

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

Android

-

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 (45)

  1. 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

  2. alexeysanuk

    Oct 31, 2018 08:18

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

  3. multimediamarkers

    Jul 05, 2018 09:35

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

  4. 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

  5. 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.

  6. 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

  7. MikePage_Artrix

    May 14, 2018 02:24

    same issue on 2017.4.3
    definitely don't have anywhere near 2gb of assets

  8. whalepaha

    May 08, 2018 10:50

    Same issue on 2017.4.1f1 LTS

  9. jsleek

    May 06, 2018 07:46

    I turned off development build and now I don't get the error anymore!

  10. atlas_r

    May 01, 2018 02:54

    Just ran across this issue in 2018.1.0b13. Won't build to Android if 360 video file is included that exceeds a few hundred megabytes.

Add comment

Log in to post comment

All about bugs

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