> Task :launcher:packageDebug FAILED

I recently upgraded to 2021.3.21f1 including a new android SDK et al.
My project was building before but even without changing to the new editor version I was getting the following errors. I’ve tried changing to the new editor, installing android up to version 33, changing the maximum JVM heap size, resetting the player settings to default and a few other things but the errors stay more or less the same.

None of this output means anything to me so I’ve included it all in the hopes that someone will spot the problem.

First Message:

Configure project :launcher
WARNING: The option setting ‘android.enableR8=false’ is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8

Task :launcher:preBuild UP-TO-DATE
Task :unityLibrary:preBuild UP-TO-DATE
Task :launcher:preDebugBuild UP-TO-DATE
Task :unityLibrary:preDebugBuild UP-TO-DATE
Task :unityLibrary:compileDebugAidl NO-SOURCE
Task :unityLibrary:packageDebugRenderscript NO-SOURCE
Task :launcher:generateDebugBuildConfig
Task :unityLibrary:compileDebugRenderscript NO-SOURCE
Task :launcher:compileDebugAidl NO-SOURCE
Task :launcher:compileDebugRenderscript NO-SOURCE
Task :unityLibrary:generateDebugResValues
Task :unityLibrary:generateDebugResources
Task :launcher:generateDebugResValues
Task :launcher:generateDebugResources
Task :launcher:createDebugCompatibleScreenManifests
Task :launcher:extractDeepLinksDebug
Task :launcher:mergeDebugShaders
Task :launcher:compileDebugShaders NO-SOURCE
Task :launcher:generateDebugAssets UP-TO-DATE
Task :launcher:processDebugJavaRes NO-SOURCE
Task :unityLibrary:packageDebugResources
Task :unityLibrary:extractDeepLinksDebug
Task :unityLibrary:compileDebugLibraryResources
Task :unityLibrary:generateDebugBuildConfig
Task :unityLibrary:mergeDebugShaders
Task :unityLibrary:compileDebugShaders NO-SOURCE
Task :unityLibrary:generateDebugAssets UP-TO-DATE
Task :launcher:checkDebugDuplicateClasses
Task :launcher:mergeDebugJniLibFolders
Task :launcher:validateSigningDebug
Task :launcher:javaPreCompileDebug
Task :launcher:mergeDebugResources
Task :launcher:desugarDebugFileDependencies
Task :launcher:mergeExtDexDebug
Task :unityLibrary:processDebugManifest
Task :unityLibrary:parseDebugLocalResources
Task :unityLibrary:javaPreCompileDebug
Task :unityLibrary:packageDebugAssets
Task :unityLibrary:processDebugJavaRes
Task :unityLibrary:mergeDebugJniLibFolders
Task :unityLibrary:bundleLibResDebug
Task :unityLibrary:generateDebugRFile

Task :unityLibrary:compileDebugJavaWithJavac

Task :unityLibrary:mergeDebugNativeLibs
Task :unityLibrary:stripDebugDebugSymbols
Task :unityLibrary:copyDebugJniLibsProjectOnly
Task :unityLibrary:bundleLibCompileToJarDebug
Task :unityLibrary:bundleLibRuntimeToJarDebug
Task :launcher:mergeDebugAssets
Task :launcher:processDebugManifest
aapt2.exe W 03-23 14:51:24 23244 17852 LoadedArsc.cpp:657] Unknown chunk type ‘200’.

Task :launcher:processDebugResources
Task :launcher:compileDebugJavaWithJavac
Task :launcher:compileDebugSources
Task :launcher:dexBuilderDebug
Task :launcher:mergeDebugJavaResource
Task :launcher:mergeLibDexDebug
Task :launcher:mergeProjectDexDebug
Task :launcher:mergeDebugNativeLibs
Task :launcher:stripDebugDebugSymbols
Task :launcher:packageDebug FAILED
43 actionable tasks: 43 executed

Second Message:

Note: C:\Users\nosna\Documents\Unity Projects\Race\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

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
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Third Message:

CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2021.3.21f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Program Files\Unity\Hub\Editor\2021.3.21f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx16000m” “assembleDebug”

Environment Variables:
RlsSvcPort = 22112
USERDOMAIN = MACHINE
ProgramFiles = C:\Program Files
TMP = C:\Users\nosna\AppData\Local\Temp
PROCESSOR_ARCHITECTURE = AMD64
EFC_11320 = 1
PROCESSOR_REVISION = 9a03
OneDriveConsumer = C:\Users\nosna\OneDrive
OS = Windows_NT
CHROME_CRASHPAD_PIPE_NAME = \.\pipe\crashpad_19944_QPFEYVWHCMUZTNFI
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 154 Stepping 3, GenuineIntel
ProgramW6432 = C:\Program Files
USERPROFILE = C:\Users\nosna
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2021.3.21f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
CommonProgramFiles = C:\Program Files\Common Files
DriverData = C:\Windows\System32\Drivers\DriverData
ComSpec = C:\Windows\system32\cmd.exe
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PUBLIC = C:\Users\Public
SystemRoot = C:\Windows
NUMBER_OF_PROCESSORS = 16
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
HOMEDRIVE = C:
TEMP = C:\Users\nosna\AppData\Local\Temp
Path = C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\nosna\AppData\Local\Microsoft\WindowsApps;
ACSvcPort = 17532
USERNAME = nosna
COMPUTERNAME = MACHINE
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
ALLUSERSPROFILE = C:\ProgramData
SystemDrive = C:
windir = C:\Windows
ZES_ENABLE_SYSMAN = 1
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
APPDATA = C:\Users\nosna\AppData\Roaming
OneDrive = C:\Users\nosna\OneDrive
PROCESSOR_LEVEL = 6
CommonProgramW6432 = C:\Program Files\Common Files
ProgramFiles(x86) = C:\Program Files (x86)
NVIDIAWHITELISTED = 0x01
SESSIONNAME = Console
LOGONSERVER = \MACHINE
LOCALAPPDATA = C:\Users\nosna\AppData\Local
HOMEPATH = \Users\nosna
SHIM_MCCOMPAT = 0x810000001
USERDOMAIN_ROAMINGPROFILE = MACHINE
ProgramData = C:\ProgramData
ORIGINAL_XDG_CURRENT_DESKTOP = undefined

stderr[
Note: C:\Users\nosna\Documents\Unity Projects\Race\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

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
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[

Configure project :launcher
WARNING: The option setting ‘android.enableR8=false’ is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8

Task :launcher:preBuild UP-TO-DATE
Task :unityLibrary:preBuild UP-TO-DATE
Task :launcher:preDebugBuild UP-TO-DATE
Task :unityLibrary:preDebugBuild UP-TO-DATE
Task :unityLibrary:compileDebugAidl NO-SOURCE
Task :unityLibrary:packageDebugRenderscript NO-SOURCE
Task :launcher:generateDebugBuildConfig
Task :unityLibrary:compileDebugRenderscript NO-SOURCE
Task :launcher:compileDebugAidl NO-SOURCE
Task :launcher:compileDebugRenderscript NO-SOURCE
Task :unityLibrary:generateDebugResValues
Task :unityLibrary:generateDebugResources
Task :launcher:generateDebugResValues
Task :launcher:generateDebugResources
Task :launcher:createDebugCompatibleScreenManifests
Task :launcher:extractDeepLinksDebug
Task :launcher:mergeDebugShaders
Task :launcher:compileDebugShaders NO-SOURCE
Task :launcher:generateDebugAssets UP-TO-DATE
Task :launcher:processDebugJavaRes NO-SOURCE
Task :unityLibrary:packageDebugResources
Task :unityLibrary:extractDeepLinksDebug
Task :unityLibrary:compileDebugLibraryResources
Task :unityLibrary:generateDebugBuildConfig
Task :unityLibrary:mergeDebugShaders
Task :unityLibrary:compileDebugShaders NO-SOURCE
Task :unityLibrary:generateDebugAssets UP-TO-DATE
Task :launcher:checkDebugDuplicateClasses
Task :launcher:mergeDebugJniLibFolders
Task :launcher:validateSigningDebug
Task :launcher:javaPreCompileDebug
Task :launcher:mergeDebugResources
Task :launcher:desugarDebugFileDependencies
Task :launcher:mergeExtDexDebug
Task :unityLibrary:processDebugManifest
Task :unityLibrary:parseDebugLocalResources
Task :unityLibrary:javaPreCompileDebug
Task :unityLibrary:packageDebugAssets
Task :unityLibrary:processDebugJavaRes
Task :unityLibrary:mergeDebugJniLibFolders
Task :unityLibrary:bundleLibResDebug
Task :unityLibrary:generateDebugRFile

Task :unityLibrary:compileDebugJavaWithJavac

Task :unityLibrary:mergeDebugNativeLibs
Task :unityLibrary:stripDebugDebugSymbols
Task :unityLibrary:copyDebugJniLibsProjectOnly
Task :unityLibrary:bundleLibCompileToJarDebug
Task :unityLibrary:bundleLibRuntimeToJarDebug
Task :launcher:mergeDebugAssets
Task :launcher:processDebugManifest
aapt2.exe W 03-23 14:51:24 23244 17852 LoadedArsc.cpp:657] Unknown chunk type ‘200’.

Task :launcher:processDebugResources
Task :launcher:compileDebugJavaWithJavac
Task :launcher:compileDebugSources
Task :launcher:dexBuilderDebug
Task :launcher:mergeDebugJavaResource
Task :launcher:mergeLibDexDebug
Task :launcher:mergeProjectDexDebug
Task :launcher:mergeDebugNativeLibs
Task :launcher:stripDebugDebugSymbols
Task :launcher:packageDebug FAILED
43 actionable tasks: 43 executed
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <ecca7c2ff94c4afda89ca5178470b3a9>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action1[T] progress) (at :0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at :0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
Rethrow as BuildFailedException: Exception of type ‘UnityEditor.Build.BuildFailedException’ was thrown.
UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at :0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at :0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at :0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <57a8ad0d1492436d8cfee9ba8e6618f8>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Fourth Message:
Build completed with a result of ‘Failed’ in 1323 seconds (1323111 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Fifth Message:

UnityEditor.BuildPlayerWindow+BuildMethodException: 4 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <57a8ad0d1492436d8cfee9ba8e6618f8>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <57a8ad0d1492436d8cfee9ba8e6618f8>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

It seems you’ve already set quite high memory number.

Here’s few things to try:

  • Delete <unity_project>\Library\Bee folder and try building.
  • Export gradle project instead and try building in Android Studio.
1 Like

Thanks for the reply.
I tried your suggestion of deleting the “Bee” folder but this had no effect. I would try the Android Studio route but I think I have a solution.
I’ve made a .package of all of the scene in the project and imported them into a new project. I then needed to go through and manually alter a few things (add layers, tweek the physics settings etc.) but it’s building now and mostly working as it should.
Not a very elegant solution and I’ll never know what the problem actually was but I’ll survive living in ignorance.
Thanks again.

I believe that I have an actual solution for this problem or at least a cause. My project has grown rather large with a lot of shadowmasks and complex scenes. It appears that there is a 2gb limit on the size of an APK. This error seems to be related to this.
This explains why it went away when I started a new project. It has since returned.

The solution is to try to use lower resolution shadowmasks and to simplify the scenes somewhat.

I hope this helps someone else.