Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted Could not create service of type FileHasher using GradleUserHomeScopeServices.createCachingFileHashe

Discussion in 'Editor & General Support' started by Only4gamers, Jan 25, 2021.

  1. Only4gamers

    Only4gamers

    Joined:
    Nov 8, 2019
    Posts:
    160
    I recently integrated Mopub to show Unity Ads and Facebook Audience Network Ads in my game. While building for Android it's giving these errors related gradle and build failing:

    On first attempt to build I get these errors:
    Code (CSharp):
    1. CommandWithNoStdoutInvokationFailure: Gradle initialization failed.
    2. UnityEditor.Android.Command.RunWithShellExecute (System.String command, System.String args, System.String workingdir, System.String errorMsg) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    3. UnityEditor.Android.AndroidJavaTools.RunJavaWithShellExecute (System.String args, System.String workingdir, System.String error) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    4. UnityEditor.Android.GradleWrapper.WarmupGradle (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingDir, System.String baseCommand) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    5. Rethrow as GradleInvokationException: Gradle initialization failed.
    6. UnityEditor.Android.GradleWrapper.WarmupGradle (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingDir, System.String baseCommand) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    7. UnityEditor.Android.PostProcessAndroidPlayer+<>c__DisplayClass3_0.<ExecuteWarmup>b__0 () (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    8. System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <9577ac7a62ef43179789031239ba8798>:0)
    9. System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <9577ac7a62ef43179789031239ba8798>:0)
    10. System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <9577ac7a62ef43179789031239ba8798>:0)
    11. System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <9577ac7a62ef43179789031239ba8798>:0)
    12. System.Threading.ThreadHelper.ThreadStart () (at <9577ac7a62ef43179789031239ba8798>:0)
    13. UnityEngine.<>c:<RegisterUECatcher>b__0_0(Object, UnhandledExceptionEventArgs)
    14.  
    15. FAILURE: Build failed with an exception.
    16.  
    17. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    18.  
    19. * What went wrong:
    20.  
    21. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    22.  
    23. Could not create service of type FileHasher using GradleUserHomeScopeServices.createCachingFileHasher().
    24.  
    25. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    26.  
    27. > Timeout waiting to lock file hash cache (C:\Users\Hi\.gradle\caches\5.1.1\fileHashes). It is currently in use by another Gradle instance.
    28.  
    29. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    30.  
    31.   Owner PID: 3776
    32.  
    33. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    34.  
    35.   Our PID: 16976
    36.  
    37. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    38.  
    39.   Owner Operation:
    40.  
    41. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    42.  
    43.   Our operation:
    44.  
    45. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    46.  
    47.   Lock file: C:\Users\Hi\.gradle\caches\5.1.1\fileHashes\fileHashes.lock
    48.  
    49. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    50.  
    51. * Try:
    52.  
    53. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    54.  
    55. 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.
    56.  
    57. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    58.  
    59. * Get more help at https://help.gradle.org
    60.  
    61. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    62.  
    63. BUILD FAILED in 1m 15s
    64.  
    65. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    66.  
    67. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    68.  
    69. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    70.  
    71. Starting a Gradle Daemon, 1 busy and 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
    72.  
    73. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    74.  
    75. CommandInvokationFailure: Gradle build failed.
    76. C:\Program Files\2019.4.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
    77.  
    78. stderr[
    79.  
    80. FAILURE: Build failed with an exception.
    81.  
    82. * What went wrong:
    83. Could not create service of type FileHasher using GradleUserHomeScopeServices.createCachingFileHasher().
    84. > Timeout waiting to lock file hash cache (C:\Users\Hi\.gradle\caches\5.1.1\fileHashes). It is currently in use by another Gradle instance.
    85.   Owner PID: 3776
    86.   Our PID: 16976
    87.   Owner Operation:
    88.   Our operation:
    89.   Lock file: C:\Users\Hi\.gradle\caches\5.1.1\fileHashes\fileHashes.lock
    90.  
    91. * Try:
    92. 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.
    93.  
    94. * Get more help at https://help.gradle.org
    95.  
    96. BUILD FAILED in 1m 15s
    97. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    98. ]
    99. stdout[
    100. Starting a Gradle Daemon, 1 busy and 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
    101. ]
    102. exit code: 1
    103. UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    104. UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    105. UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    106. UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    107. UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    108. Rethrow as GradleInvokationException: Gradle build failed
    109. UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    110. UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    111. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    112. Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
    113. UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    114. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    115. 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) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    116. UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <303ae0e7a8d8441ab049e592bd1e2100>:0)
    117. 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) (at <7d90b28560b644ce87b8263efcc36eed>:0)
    118. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    119.  
    120. Build completed with a result of 'Failed' in 549 seconds (549476 ms)
    121. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    122.  
    123. UnityEditor.BuildPlayerWindow+BuildMethodException: 23 errors
    124.   at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002bb] in <7d90b28560b644ce87b8263efcc36eed>:0
    125.   at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <7d90b28560b644ce87b8263efcc36eed>:0
    126. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    127.  

    When I restarted my PC and try bulding I get different and more errors:
    More than one file was found with OS independent path:

    Capture3.PNG

    Code (CSharp):
    1. Note: D:\Unity Backups\Endless 10\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
    2.  
    3. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    4.  
    5. Note: Recompile with -Xlint:deprecation for details.
    6.  
    7. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    8.  
    9. FAILURE: Build failed with an exception.
    10.  
    11. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    12.  
    13. * What went wrong:
    14.  
    15. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    16.  
    17. Execution failed for task ':launcher:transformResourcesWithMergeJavaResForRelease'.
    18.  
    19. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    20.  
    21. > More than one file was found with OS independent path 'META-INF/androidx.lifecycle_lifecycle-runtime.version'
    22.  
    23. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    24.  
    25. * Try:
    26.  
    27. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    28.  
    29. 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.
    30.  
    31. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    32.  
    33. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    34.  
    35. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    36.  
    37. Starting a Gradle Daemon, 1 busy and 1 incompatible and 2 stopped Daemons could not be reused, use --status for details
    38.  
    39. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    40.  
    41. > Task :unityLibrary:preBuild UP-TO-DATE
    42.  
    43. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    44.  
    45. > Task :launcher:preBuild UP-TO-DATE
    46.  
    47. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    48.  
    49. > Task :unityLibrary:GooglePlayGamesManifest.plugin:preBuild UP-TO-DATE
    50.  
    51. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    52.  
    53. > Task :unityLibrary:MoPub.plugin:preBuild UP-TO-DATE
    54.  
    55. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    56.  
    57. And so many errors..........
    In Mopub integration guide they are giving some hint about these errors maybe:

    If you are integrating with v5.6.0 or later of the MoPub SDK, specify the sourceCompatibility and targetCompatibility as below to prevent potential compilation errors:
    Code (CSharp):
    1. android {
    2.     compileOptions {
    3.         sourceCompatibility JavaVersion.VERSION_1_8
    4.         targetCompatibility JavaVersion.VERSION_1_8
    5.     }
    6. }
    But I am not sure where to insert above code. Is anyone familiar with this build error? Please help.
    My Unity Version is 2019.4.16f1 and using latest version of Ad netwotk SDKs, plugin etc.
    Thanks.
     
    Last edited: Jan 25, 2021
unityunity