SubScene build error in Android

Hello,
I am creating a big world with ECS’s SubScenes. The world is about 500m x 500m with game objects of totally 2G memory. I spitted them in 15 sub scenes.
Environment:
Unity 2020.3.6f1
URP

And there is a android build error when using build configuration:
https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/HybridURPSamples/Assets/BuildConfiguration

Error:
Build HybridURPAndroidBuildSettings failed after 2.57m.

Configure project :launcher
WARNING: The option ‘android.enableR8’ is deprecated and should not be used anymore.
It will be removed in a future version of the Android Gradle plugin, and will no longer allow you to disable R8.
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\28.0.3\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
Task :launcher:preBuild UP-TO-DATE
Task :launcher:preDebugBuild UP-TO-DATE
Task :unityLibrary:preBuild UP-TO-DATE
Task :unityLibrary:preDebugBuild UP-TO-DATE
Task :unityLibrary:compileDebugAidl NO-SOURCE
Task :launcher:compileDebugAidl NO-SOURCE
Task :unityLibrary:packageDebugRenderscript NO-SOURCE
Task :launcher:compileDebugRenderscript NO-SOURCE
Task :launcher:generateDebugBuildConfig UP-TO-DATE
Task :unityLibrary:compileDebugRenderscript NO-SOURCE
Task :unityLibrary:generateDebugBuildConfig UP-TO-DATE
Task :unityLibrary:generateDebugResValues UP-TO-DATE
Task :unityLibrary:generateDebugResources UP-TO-DATE
Task :unityLibrary:packageDebugResources UP-TO-DATE
Task :unityLibrary:parseDebugLocalResources UP-TO-DATE
Task :unityLibrary:javaPreCompileDebug UP-TO-DATE
Task :launcher:mainApkListPersistenceDebug UP-TO-DATE
Task :launcher:generateDebugResValues UP-TO-DATE
Task :launcher:generateDebugResources UP-TO-DATE
Task :launcher:mergeDebugResources UP-TO-DATE
Task :launcher:createDebugCompatibleScreenManifests UP-TO-DATE
Task :launcher:extractDeepLinksDebug UP-TO-DATE
Task :unityLibrary:extractDeepLinksDebug UP-TO-DATE
Task :unityLibrary:compileDebugLibraryResources UP-TO-DATE
Task :launcher:mergeDebugShaders UP-TO-DATE
Task :launcher:compileDebugShaders UP-TO-DATE
Task :launcher:generateDebugAssets UP-TO-DATE
Task :unityLibrary:mergeDebugShaders UP-TO-DATE
Task :unityLibrary:compileDebugShaders UP-TO-DATE
Task :unityLibrary:generateDebugAssets UP-TO-DATE
Task :unityLibrary:packageDebugAssets
Task :launcher:mergeDebugAssets
Task :launcher:processDebugJavaRes NO-SOURCE
Task :unityLibrary:processDebugJavaRes NO-SOURCE
Task :unityLibrary:bundleLibResDebug UP-TO-DATE
Task :launcher:mergeDebugJavaResource UP-TO-DATE
Task :launcher:checkDebugDuplicateClasses UP-TO-DATE
Task :launcher:desugarDebugFileDependencies UP-TO-DATE
Task :launcher:mergeExtDexDebug UP-TO-DATE
Task :launcher:mergeDebugJniLibFolders UP-TO-DATE
Task :unityLibrary:mergeDebugJniLibFolders
Task :launcher:validateSigningDebug UP-TO-DATE
Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
Task :unityLibrary:mergeDebugJavaResource UP-TO-DATE
Task :unityLibrary:processDebugManifest
Task :unityLibrary:generateDebugRFile UP-TO-DATE
Task :unityLibrary:compileDebugJavaWithJavac UP-TO-DATE
Task :unityLibrary:bundleLibCompileDebug UP-TO-DATE
Task :launcher:javaPreCompileDebug UP-TO-DATE
Task :launcher:processDebugManifest
Task :launcher:processDebugResources
Task :launcher:compileDebugJavaWithJavac UP-TO-DATE
Task :launcher:compileDebugSources UP-TO-DATE
Task :unityLibrary:bundleLibRuntimeDebug UP-TO-DATE
Task :launcher:dexBuilderDebug UP-TO-DATE
Task :launcher:mergeDexDebug UP-TO-DATE
Task :unityLibrary:extractDebugAnnotations UP-TO-DATE
Task :unityLibrary:mergeDebugGeneratedProguardFiles UP-TO-DATE
Task :unityLibrary:mergeDebugConsumerProguardFiles UP-TO-DATE
Task :unityLibrary:syncDebugLibJars UP-TO-DATE
Task :unityLibrary:compileDebugSources UP-TO-DATE
Task :unityLibrary:mergeDebugNativeLibs
Task :unityLibrary:stripDebugDebugSymbols
Task :unityLibrary:copyDebugJniLibsProjectOnly
Task :unityLibrary:copyDebugJniLibsProjectAndLocalJars
Task :launcher:mergeDebugNativeLibs
Task :unityLibrary:bundleDebugAar
Task :unityLibrary:assembleDebug
Task :launcher:stripDebugDebugSymbols
Task :launcher:packageDebug FAILED
52 actionable tasks: 14 executed, 38 up-to-date
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:launcher:packageDebug’.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
java.lang.OutOfMemoryError (no error message)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  • Get more help at https://help.gradle.org
    BUILD FAILED in 1m 7s
    UnityEngine.Debug:LogError (object,UnityEngine.Object)
    Unity.Build.ResultBase:LogResult () (at Library/PackageCache/com.unity.platforms@0.10.0-preview.10/Editor/Unity.Build/ResultBase.cs:65)
    Unity.Build.Editor.BuildConfigurationInspector/<>c:<.cctor>b__34_0 (Unity.Build.BuildConfiguration) (at Library/PackageCache/com.unity.platforms@0.10.0-preview.10/Editor/Unity.Build.Editor/BuildConfigurationInspector.cs:42)
    Unity.Build.Editor.BuildConfigurationInspector/<>c__DisplayClass30_0:b__1 () (at Library/PackageCache/com.unity.platforms@0.10.0-preview.10/Editor/Unity.Build.Editor/BuildConfigurationInspector.cs:128)
    UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Does anyone knows the reason and how to solve this problem?

This is probably not relevant anymore, but I also hit this first time I tried building for android, (Apple M1 with 8GB). I think it’s just an out of memory error. At least for me, just shutting down memory hogging programs like vscode, firefox for the build time worked.

1 Like