Timeout waiting to lock journal cache
セキュリティソフト(ESETなど)を入れている場合に、Gradle周りでビルドが終わらないなどの不都合が発生することがあります。
特に、Android Studioを複数起動した際に、下記のような「Timeout waiting to lock journal cache」というエラーが出てしまうのは開発効率的な意味でとても面倒な問題です。
Gradle could not start your build.
> Cannot create service of type BuildSessionActionExecutor using method LauncherServices$ToolingBuildSessionScopeServices.createActionExecutor() as there is a problem with parameter #21 of type FileSystemWatchingInformation.
> Cannot create service of type BuildLifecycleAwareVirtualFileSystem using method VirtualFileSystemServices$GradleUserHomeServices.createVirtualFileSystem() as there is a problem with parameter #7 of type GlobalCacheLocations.
> Cannot create service of type GlobalCacheLocations using method GradleUserHomeScopeServices.createGlobalCacheLocations() as there is a problem with parameter #1 of type List<GlobalCache>.
> Could not create service of type FileAccessTimeJournal using GradleUserHomeScopeServices.createFileAccessTimeJournal().
> Timeout waiting to lock journal cache (/Users/xxxxx/.gradle/caches/journal-1). It is currently in use by another Gradle instance.
Owner PID: 51888
Our PID: 52417
Owner Operation:
Our operation:
Lock file: /Users/xxxxx/.gradle/caches/journal-1/journal-1.lock
エラーの対応としては、プロセスをkillすることで一旦解消できはしますが、毎回行うのは少々面倒です。
$ kill -9 51888
Gradle user home を設定する
Gradle user home がデフォルトだと /Users/xxxxx/.gradle
として設定されているので、これを別に設定すれば回避できるようです。
デフォルト( /Users/xxxxx/.gradle ) |
別指定( /Users/xxxxx/.gradle2 ) |
---|---|
![]() |
![]() |
Override the default location where Gradle stores downloaded files, e.g. to tune anti-virus software on Windows
と記載がありますが、Macでも言えそうですね。
デメリット
一応これで問題なく動いているようですが、デメリットとしては
- Gradleのキャッシュなどがないため初回ビルドに時間がかかる
- 容量を食う
があげられるかなと思います。
関連リンク