Search code examples
gradlekotlin-multiplatform-mobile

KMM: Build fails caused by being locked by another Gradle instance, when switching the OS to build


I created a KMM project (ios framework distribution is CocoaPods) and just built the application without changing the code.

When I build the iOS application after building the Android application (even if I run Android after iOS), it fails with a following error.

Gradle could not start your build.
> Could not create service of type ResourceSnapshotterCacheService using GradleUserHomeServices.createResourceSnapshotterCacheService().
   > Timeout waiting to lock file hash cache (/Users/<user-name>/.gradle/caches/6.7.1/fileHashes). It is currently in use by another Gradle instance.
     Owner PID: 57033
     Our PID: 57624
     Owner Operation: 
     Our operation: 
     Lock file: /Users/<user-name>/.gradle/caches/6.7.1/fileHashes/fileHashes.lock

If I kill the another Gradle process and delete the lock file, the build will succeed. But I can't do this every time.

I don't know what's wrong and differences from others.

BTW, I created the project that supports improved Gradle task embedAndSignAppleFrameworkForXcode.


My environment is below...

  • macOS Big Sur 11.4
  • Android Studio 4.2.2
  • Kotlin 1.5.21
  • Kotlin Multiplatform Mobile 0.2.6 (202-1.5.10-release-894-IJ)-8
  • Gradle 6.7.1
  • AGP 4.2.2
  • Java 11.0.8 2020-07-14 LTS
  • Xcode: 12.5.1 (12E507)

Solution

  • Try updating gradle to 7.1.1 (latest version)

    If this doesn't help, consider creating an issue on jetbrains issue tracker, because this doesn't seems like a typical problem and may be solved much faster there