Unity batchmode build fails on task : "Building Gradle project"

I’m trying to set up jenkins to make builds and was struggled with this annoying error. Sometimes builds passing through but I can’t understand why is it happening.

Logs


Android PostProcess task "Exporting project" took 3636.4522 ms
DisplayProgressbar: Building Gradle project
Starting a Gradle Daemon, 2 incompatible and 6 stopped Daemons could not be reused, use --status for details

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

> Task :launcher:preBuild UP-TO-DATE
> Task :unityLibrary:preBuild UP-TO-DATE
> Task :unityLibrary:preReleaseBuild UP-TO-DATE
> Task :launcher:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:compileReleaseAidl NO-SOURCE
> Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
> Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
> Task :launcher:generateReleaseBuildConfig
> Task :unityLibrary:generateReleaseBuildConfig
> Task :launcher:compileReleaseAidl NO-SOURCE
> Task :launcher:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:generateReleaseResValues
> Task :unityLibrary:generateReleaseResources
> Task :launcher:mainApkListPersistenceRelease
> Task :launcher:generateReleaseResValues
> Task :launcher:generateReleaseResources
> Task :launcher:createReleaseCompatibleScreenManifests
> Task :launcher:extractDeepLinksRelease
> Task :launcher:prepareLintJar
> Task :unityLibrary:packageReleaseResources
> Task :launcher:checkReleaseDuplicateClasses
> Task :unityLibrary:extractDeepLinksRelease
> Task :launcher:mergeReleaseShaders
> Task :launcher:compileReleaseShaders
> Task :launcher:generateReleaseAssets
> Task :launcher:processReleaseJavaRes NO-SOURCE
> Task :unityLibrary:parseReleaseLocalResources
> Task :launcher:mergeReleaseJniLibFolders
> Task :unityLibrary:mergeReleaseShaders
> Task :unityLibrary:compileReleaseShaders
> Task :unityLibrary:generateReleaseAssets
> Task :launcher:validateSigningRelease
> Task :launcher:mergeReleaseResources
> Task :launcher:desugarReleaseFileDependencies
> Task :launcher:mergeExtDexRelease

> Task :unityLibrary:processReleaseManifest
F:\SHARE_ALL\TRANZIT\GWPRO_vr_trainers_projects_261021\VR_Trainers_GWPro_3\Temp\gradleOut\unityLibrary\src\main\AndroidManifest.xml:3:3-23:17 Warning:
	application@android:theme was tagged at AndroidManifest.xml:3 to replace other declarations but no other declaration present

> Task :unityLibrary:packageReleaseAssets
> Task :unityLibrary:compileReleaseLibraryResources
> Task :unityLibrary:processReleaseJavaRes NO-SOURCE
> Task :unityLibrary:mergeReleaseJniLibFolders
> Task :unityLibrary:prepareLintJarForPublish
> Task :unityLibrary:mergeReleaseNativeLibs
> Task :unityLibrary:stripReleaseDebugSymbols
> Task :unityLibrary:copyReleaseJniLibsProjectOnly
> Task :unityLibrary:javaPreCompileRelease
> Task :unityLibrary:bundleLibResRelease
> Task :unityLibrary:generateReleaseRFile

> Task :unityLibrary:compileReleaseJavaWithJavac

> Task :unityLibrary:bundleLibRuntimeRelease
> Task :unityLibrary:bundleLibCompileRelease
> Task :launcher:mergeReleaseAssets
> Task :launcher:processReleaseManifest
> Task :launcher:processReleaseResources FAILED
> Task :launcher:javaPreCompileRelease
39 actionable tasks: 39 executed

UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
UnityEditor.Android.GradleInvokationException:ParseAndShowException()
UnityEditor.Android.PostProcessor.PostProcessRunner:RunAllTasks(PostProcessorContext)
UnityEditor.Android.PostProcessAndroidPlayer:PostProcess(BuildTarget, String, String, String, String, String, String, BuildOptions, RuntimeClassRegistry, BuildReport)
UnityEditor.Android.AndroidBuildPostprocessor:PostProcess(BuildPostProcessArgs, BuildProperties&)
UnityEditor.PostprocessBuildPlayer:Postprocess(BuildTargetGroup, BuildTarget, String, String, String, Int32, Int32, BuildOptions, RuntimeClassRegistry, BuildReport)
UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, String[], Boolean)
UnityEditor.BuildPipeline:BuildPlayerInternal(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, String[])
UnityEditor.BuildPipeline:BuildPlayer(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, String[])
UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions)
UnityEditor.BuildPipeline:BuildPlayer(EditorBuildSettingsScene[], String, BuildTarget, BuildOptions)
ContinuousDevelopment.BuildConveyor_V2:StartAutoBuild() (at Assets\VRCommonComponents\InternalAssets\ContinuousDevelopment\Editor\BuildConveyor_V2.cs:279)
 
(Filename: Assets/VRCommonComponents/InternalAssets/ContinuousDevelopment/Editor/BuildConveyor_V2.cs Line: 279)

Note: F:\SHARE_ALL\TRANZIT\GWPRO_vr_trainers_projects_261021\VR_Trainers_GWPro_3\Temp\gradleOut\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:processReleaseResources'.
> Could not resolve all files for configuration ':launcher:releaseRuntimeClasspath'.
   > Failed to transform artifact 'wvr_client.aar (:wvr_client:)' to match attributes {artifactType=android-compiled-dependencies-resources}.
      > Execution failed for AarResourcesCompilerTransform: C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-2\files-2.1\ffc089f975feebdb27a598fb9e41f55d\wvr_client.
         > Android resource compilation failed
           AAPT: C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-2\files-2.1\b656dfa2b35dadece8cffa16757a3809\com.htc.vr.client.bootstrap: error: The system cannot find the file specified. (2).
           
               

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

UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
UnityEditor.Android.GradleInvokationException:ParseAndShowException()
UnityEditor.Android.PostProcessor.PostProcessRunner:RunAllTasks(PostProcessorContext)
UnityEditor.Android.PostProcessAndroidPlayer:PostProcess(BuildTarget, String, String, String, String, String, String, BuildOptions, RuntimeClassRegistry, BuildReport)
UnityEditor.Android.AndroidBuildPostprocessor:PostProcess(BuildPostProcessArgs, BuildProperties&)
UnityEditor.PostprocessBuildPlayer:Postprocess(BuildTargetGroup, BuildTarget, String, String, String, Int32, Int32, BuildOptions, RuntimeClassRegistry, BuildReport)
UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, String[], Boolean)
UnityEditor.BuildPipeline:BuildPlayerInternal(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, String[])
UnityEditor.BuildPipeline:BuildPlayer(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, String[])
UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions)
UnityEditor.BuildPipeline:BuildPlayer(EditorBuildSettingsScene[], String, BuildTarget, BuildOptions)
ContinuousDevelopment.BuildConveyor_V2:StartAutoBuild() (at Assets\VRCommonComponents\InternalAssets\ContinuousDevelopment\Editor\BuildConveyor_V2.cs:279)
 
(Filename: Assets/VRCommonComponents/InternalAssets/ContinuousDevelopment/Editor/BuildConveyor_V2.cs Line: 279)

CommandInvokationFailure: Gradle build failed. 
C:\Program Files\Unity\Hub\Editor\2020.1.17f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2020.1.17f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.6.4.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

stderr[
Note: F:\SHARE_ALL\TRANZIT\GWPRO_vr_trainers_projects_261021\VR_Trainers_GWPro_3\Temp\gradleOut\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:processReleaseResources'.
> Could not resolve all files for configuration ':launcher:releaseRuntimeClasspath'.
   > Failed to transform artifact 'wvr_client.aar (:wvr_client:)' to match attributes {artifactType=android-compiled-dependencies-resources}.
      > Execution failed for AarResourcesCompilerTransform: C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-2\files-2.1\ffc089f975feebdb27a598fb9e41f55d\wvr_client.
         > Android resource compilation failed
           AAPT: C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-2\files-2.1\b656dfa2b35dadece8cffa16757a3809\com.htc.vr.client.bootstrap: error: The system cannot find the file specified. (2).
           
               

* 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 35s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[
Starting a Gradle Daemon, 2 incompatible and 6 stopped Daemons could not be reused, use --status for details

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

> Task :launcher:preBuild UP-TO-DATE
> Task :unityLibrary:preBuild UP-TO-DATE
> Task :unityLibrary:preReleaseBuild UP-TO-DATE
> Task :launcher:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:compileReleaseAidl NO-SOURCE
> Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
> Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
> Task :launcher:generateReleaseBuildConfig
> Task :unityLibrary:generateReleaseBuildConfig
> Task :launcher:compileReleaseAidl NO-SOURCE
> Task :launcher:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:generateReleaseResValues
> Task :unityLibrary:generateReleaseResources
> Task :launcher:mainApkListPersistenceRelease
> Task :launcher:generateReleaseResValues
> Task :launcher:generateReleaseResources
> Task :launcher:createReleaseCompatibleScreenManifests
> Task :launcher:extractDeepLinksRelease
> Task :launcher:prepareLintJar
> Task :unityLibrary:packageReleaseResources
> Task :launcher:checkReleaseDuplicateClasses
> Task :unityLibrary:extractDeepLinksRelease
> Task :launcher:mergeReleaseShaders
> Task :launcher:compileReleaseShaders
> Task :launcher:generateReleaseAssets
> Task :launcher:processReleaseJavaRes NO-SOURCE
> Task :unityLibrary:parseReleaseLocalResources
> Task :launcher:mergeReleaseJniLibFolders
> Task :unityLibrary:mergeReleaseShaders
> Task :unityLibrary:compileReleaseShaders
> Task :unityLibrary:generateReleaseAssets
> Task :launcher:validateSigningRelease
> Task :launcher:mergeReleaseResources
> Task :launcher:desugarReleaseFileDependencies
> Task :launcher:mergeExtDexRelease

> Task :unityLibrary:processReleaseManifest
F:\SHARE_ALL\TRANZIT\GWPRO_vr_trainers_projects_261021\VR_Trainers_GWPro_3\Temp\gradleOut\unityLibrary\src\main\AndroidManifest.xml:3:3-23:17 Warning:
	application@android:theme was tagged at AndroidManifest.xml:3 to replace other declarations but no other declaration present

> Task :unityLibrary:packageReleaseAssets
> Task :unityLibrary:compileReleaseLibraryResources
> Task :unityLibrary:processReleaseJavaRes NO-SOURCE
> Task :unityLibrary:mergeReleaseJniLibFolders
> Task :unityLibrary:prepareLintJarForPublish
> Task :unityLibrary:mergeReleaseNativeLibs
> Task :unityLibrary:stripReleaseDebugSymbols
> Task :unityLibrary:copyReleaseJniLibsProjectOnly
> Task :unityLibrary:javaPreCompileRelease
> Task :unityLibrary:bundleLibResRelease
> Task :unityLibrary:generateReleaseRFile

> Task :unityLibrary:compileReleaseJavaWithJavac

> Task :unityLibrary:bundleLibRuntimeRelease
> Task :unityLibrary:bundleLibCompileRelease
> Task :launcher:mergeReleaseAssets
> Task :launcher:processReleaseManifest
> Task :launcher:processReleaseResources FAILED
> Task :launcher:javaPreCompileRelease
39 actionable tasks: 39 executed
]
exit code: 1
  at UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) [0x00033] in <3746c56c485a40cda2a56050de658f5e>:0 
  at UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) [0x0002d] in <3746c56c485a40cda2a56050de658f5e>:0 
  at UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) [0x0000a] in <3746c56c485a40cda2a56050de658f5e>:0 
  at UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) [0x0001f] in <3746c56c485a40cda2a56050de658f5e>:0 
  at UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) [0x0002a] in <3746c56c485a40cda2a56050de658f5e>:0 
Rethrow as GradleInvokationException: Gradle build failed
  at UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) [0x0004b] in <3746c56c485a40cda2a56050de658f5e>:0 
  at UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) [0x000d1] in <3746c56c485a40cda2a56050de658f5e>:0 
  at UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) [0x00078] in <3746c56c485a40cda2a56050de658f5e>:0 
Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
  at UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) [0x00020] in <3746c56c485a40cda2a56050de658f5e>:0 
  at UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) [0x0011a] in <3746c56c485a40cda2a56050de658f5e>:0 
  at UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) [0x003cb] in <3746c56c485a40cda2a56050de658f5e>:0 
  at UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) [0x00001] in <3746c56c485a40cda2a56050de658f5e>:0 
  at UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, 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) [0x000dc] in <c84609c921cb488481d7d8a5fcdf9588>:0 
UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, String[], Boolean)
UnityEditor.BuildPipeline:BuildPlayerInternal(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, String[])
UnityEditor.BuildPipeline:BuildPlayer(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, String[])
UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions)
UnityEditor.BuildPipeline:BuildPlayer(EditorBuildSettingsScene[], String, BuildTarget, BuildOptions)
ContinuousDevelopment.BuildConveyor_V2:StartAutoBuild() (at Assets\VRCommonComponents\InternalAssets\ContinuousDevelopment\Editor\BuildConveyor_V2.cs:279)
 
(Filename: <3746c56c485a40cda2a56050de658f5e> Line: 0)

Unloading 670 Unused Serialized files (Serialized files now loaded: 0)
System memory in use before: 0.51 GB.
System memory in use after: 0.51 GB.

Unloading 741 unused Assets to reduce memory usage. Loaded Objects now: 17280.
Total: 919.110300 ms (FindLiveObjects: 2.155000 ms CreateObjectMapping: 0.299400 ms MarkObjects: 914.851400 ms  DeleteObjects: 1.803700 ms)

Unloading 45 Unused Serialized files (Serialized files now loaded: 0)
LightingSettings: switching bake backend from 1 to 2.
Loaded scene 'Temp/__Backupscenes/0.backup'
	Deserialize:            201.877 ms
	Integration:            3350.933 ms
	Integration of assets:  2.579 ms
	Thread Wait Time:       9.229 ms
	Total Operation Time:   3564.618 ms
System memory in use before: 0.53 GB.
System memory in use after: 0.54 GB.

Unloading 20 unused Assets to reduce memory usage. Loaded Objects now: 37273.
Total: 934.905700 ms (FindLiveObjects: 3.978300 ms CreateObjectMapping: 0.870700 ms MarkObjects: 929.970300 ms  DeleteObjects: 0.085400 ms)


Aborting batchmode due to failure:
executeMethod method ContinuousDevelopment.BuildConveyor_V2.StartAutoBuild threw exception.

Exception: BuildPlayer failure!
  at ContinuousDevelopment.BuildConveyor_V2.StartAutoBuild () [0x0045f] in F:\SHARE_ALL\TRANZIT\GWPRO_vr_trainers_projects_261021\VR_Trainers_GWPro_3\Assets\VRCommonComponents\InternalAssets\ContinuousDevelopment\Editor\BuildConveyor_V2.cs:289 
 
(Filename: Assets/VRCommonComponents/InternalAssets/ContinuousDevelopment/Editor/BuildConveyor_V2.cs Line: 289)

executeMethod method ContinuousDevelopment.BuildConveyor_V2.StartAutoBuild threw exception. 
(Filename: C:\buildslave\unity\build\Runtime/Utilities/Argv.cpp Line: 396)

Exiting without the bug reporter. Application will terminate with return code 1Process leaked file descriptors. See https://www.jenkins.io/redirect/troubleshooting/process-leaked-file-descriptors for more information
FATAL: Unity3d command line execution failed with status 1
Build step 'Invoke Unity3d Editor' marked build as failure
Finished: FAILURE

@Aieko did you find a resolution to this?

We installed a new drive to our build server, and since moving our projects and jenkins build process to that new drive, all Android platform builds fail with the same error you have.

I can still run the builds on the old drive and the error does not show then. I’ve been through all the drive permissions and there’s no issues there.

Gradle is in C drive
Projects built from E drive work
Projects built from F drive have the gradle error.

For anyone else that does stumble over this thread/issue, I resolved by setting an Environment Variable for GRADLE_USER_HOME in windows to c:/gradle-cache The path for system gradle may have been too long…