LoginSignup
8
4

More than 1 year has passed since last update.

Android Studioを複数起動した際に「Timeout waiting to lock journal cache」というエラーが出た時に…

Posted at

Timeout waiting to lock journal cache :joy:

セキュリティソフト(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 を設定する:bulb:

Gradle user home がデフォルトだと /Users/xxxxx/.gradle として設定されているので、これを別に設定すれば回避できるようです。

デフォルト( /Users/xxxxx/.gradle 別指定( /Users/xxxxx/.gradle2
スクリーンショット_2023-02-11_午前5_36_50.png スクリーンショット_2023-02-11_午前5_43_52.png

Override the default location where Gradle stores downloaded files, e.g. to tune anti-virus software on Windows

と記載がありますが、Macでも言えそうですね。

デメリット :slight_frown:

一応これで問題なく動いているようですが、デメリットとしては

  • Gradleのキャッシュなどがないため初回ビルドに時間がかかる
  • 容量を食う

があげられるかなと思います。

関連リンク

8
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
4