UE5.2.1 Meta Quest Development, "Task :app:packageRelease FAILED" "ActionFacade" "java.io.IOException"

I’m making a game for Quest 3 in UE 5.2.1. I’ve been able to make development builds fine, but now I want to test the game without print strings or debug lines, so I set the Build Configuration to “Shipping” and checked “For Distribution” as true in the project settings. I also created a .keystore and set that up in Platforms/Android/Distribution Signing with the correct password and everything.

When I package it via Platforms>Android>Package Project with “Android (ASTC)” and “Shipping” selected, It builds fine until it reaches “> Task :app:packageRelease”, then it gives me this:

> Task :app:packageRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > java.io.IOException: Failed to delete 'C:\Users\marigo8\AppData\Local\Temp\tempdir_3646414561775212839\temp_507234823964723399.data'

* 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 3m 37s
63 actionable tasks: 11 executed, 52 up-to-date
==============================================================================
ERROR: cmd.exe failed with args /c "C:\Repos\MushroomRepo\Mushroom2023_UE52\Intermediate\Android\arm64\gradle\rungradle.bat" :app:assembleRelease
       (see C:\Users\marigo8\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_5.2\Log.txt for full exception trace)

BuildException: cmd.exe failed with args /c "C:\Repos\MushroomRepo\Mushroom2023_UE52\Intermediate\Android\arm64\gradle\rungradle.bat" :app:assembleRelease
   at UnrealBuildTool.UEDeployAndroid.RunCommandLineProgramWithExceptionAndFiltering(String WorkingDirectory, String Command, String Params, ILogger Logger, String OverrideDesc, Boolean bUseShellExecute) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Android\UEDeployAndroid.cs:line 1879
   at UnrealBuildTool.UEDeployAndroid.MakeApk(AndroidToolChain ToolChain, String ProjectName, TargetType InTargetType, String ProjectDirectory, String OutputPath, String EngineDirectory, Boolean bForDistribution, String CookFlavor, UnrealTargetConfiguration Configuration, Boolean bMakeSeparateApks, Boolean bIncrementalPackage, Boolean bDisallowPackagingDataInApk, Boolean bDisallowExternalFilesDir, Boolean bSkipGradleBuild) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Android\UEDeployAndroid.cs:line 4908
   at UnrealBuildTool.UEDeployAndroid.PrepForUATPackageOrDeploy(FileReference ProjectFile, String ProjectName, DirectoryReference ProjectDirectory, String ExecutablePath, String EngineDirectory, Boolean bForDistribution, String CookFlavor, UnrealTargetConfiguration Configuration, Boolean bIsDataDeploy, Boolean bSkipGradleBuild) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Android\UEDeployAndroid.cs:line 5507
   at AndroidPlatform.Package(ProjectParams Params, DeploymentContext SC, Int32 WorkingCL) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\AutomationTool\Android\AndroidPlatform.Automation.cs:line 0
   at AutomationScripts.Project.Package(ProjectParams Params, Int32 WorkingCL) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\AutomationTool\Scripts\PackageCommand.Automation.cs:line 48
   at BuildCookRun.DoBuildCookRun(ProjectParams Params) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:line 223
   at BuildCookRun.ExecuteBuild() in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:line 42
   at AutomationTool.BuildCommand.Execute() in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\AutomationTool\AutomationUtils\BuildCommand.cs:line 344
   at AutomationTool.BuildCommand.ExecuteAsync() in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\AutomationTool\AutomationUtils\BuildCommand.cs:line 353
   at AutomationTool.Automation.ExecuteAsync(List`1 CommandsToExecute, Dictionary`2 Commands) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\AutomationTool\AutomationUtils\Automation.cs:line 257
   at AutomationTool.Automation.ProcessAsync(ParsedCommandLine AutomationToolCommandLine, StartupTraceListener StartupListener, HashSet`1 ScriptModuleAssemblies) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\AutomationTool\AutomationUtils\Automation.cs:line 156
==============================================================================
AutomationTool executed for 0h 10m 47s
AutomationTool exiting with ExitCode=1 (Error_Unknown)

Seems like the main issue is that a file in the temp folder isn’t being allowed for deletion. I don’t know what could be causing this.

When I untick “For Distribution” it compiles fine, but obviously I want to be able to make a distribution build.

I’ve verified that my keystore password is set correctly. I’ve tried reinstalling android studio several times and even tried using a separate installation for jdk instead of Android Studio’s built-in one. I’ve tried different sdk api levels. Nothing is working. I have bitdefender but that isn’t blocking any of the temp files from being deleted, at least to my knowledge. Moving the build destination folder to the C Drive doesn’t work either.

I’ve been trying to resolve this all day and am currently questioning my career choices does anyone have any idea what I could be doing wrong please help