You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

macOS下Android Studio启动失败提示“Cannot Lock System Folders”求助

Fix "Cannot Lock System Folders" Error on Android Studio (macOS)

Hey there, sorry to hear you're stuck with this frustrating lock issue on macOS—let's work through targeted fixes that address your specific setup, since Windows solutions won't apply here.

Step 1: Reset Folder Permissions (Most Likely Fix)

macOS is strict about file ownership, and this error almost always stems from Android Studio lacking write access to its core directories. Here's how to fix it:

  1. Open Terminal (find it in Launchpad > Other > Terminal).
  2. Run these commands one by one (enter your macOS password when prompted—Terminal won't show typed characters, which is normal):
    • Take ownership of the Android Studio app itself:
      sudo chown -R $(whoami):admin /Applications/Android\ Studio.app
      
    • Fix permissions for your default Android SDK folder:
      sudo chown -R $(whoami):admin ~/Library/Android/sdk
      
    • Clear and reset cache/config directories (these often hold stale locks):
      # Delete old cache files
      rm -rf ~/Library/Caches/Google/AndroidStudio*
      # Reset cache folder ownership
      sudo chown -R $(whoami):admin ~/Library/Caches/Google
      # Delete old config files
      rm -rf ~/Library/Application\ Support/Google/AndroidStudio*
      # Reset config folder ownership
      sudo chown -R $(whoami):admin ~/Library/Application\ Support/Google
      

Step 2: Kill Stuck Background Processes

Sometimes leftover Android Studio/Java processes hold locks on folders even after you close the app. Let's clear them:

  1. Open Activity Monitor (Launchpad > Other > Activity Monitor).
  2. Use the search bar to look for:
    • Android Studio
    • java (Android Studio runs on a Java runtime)
  3. Select any matching processes, click the X button in the top-left corner, and choose Force Quit.
  4. Try launching Android Studio again.

Step 3: Resolve Java Environment Conflicts

If you have multiple Java versions installed (e.g., via Homebrew), it might clash with Android Studio's built-in JDK. Test using the app's own runtime:

  1. In Terminal, set a temporary Java home to Android Studio's built-in JDK:
    export JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"
    
  2. Launch Android Studio directly from Terminal:
    open /Applications/Android\ Studio.app
    

If this works, you can make this permanent by adding the export line to your ~/.zshrc or ~/.bash_profile file (depending on your default shell).

Step 4: Dig Into Logs for Exact Locked Folder

If none of the above works, check Android Studio's logs to pinpoint the exact folder causing the lock:

  1. Navigate to ~/Library/Logs/Google/AndroidStudio<YourVersion>/idea.log (replace <YourVersion> with your Studio version, e.g., AndroidStudio2023.1).
  2. Open the file with TextEdit, search for Cannot Lock System Folders, and look at the surrounding lines—they'll name the problematic folder. You can then reapply the permission fix from Step 1 to that specific directory.

内容的提问来源于stack exchange,提问作者unknown

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:45:29