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

Linux Mint模拟器中Flutter项目Gradle超时运行失败求助

Fixing Gradle Timeout & File Lock Issues for Flutter on Linux Mint Tina

Hey there! Let's work through this Gradle timeout and file lock issue you're hitting on Linux Mint Tina with your first Flutter project. I've dealt with similar roadblocks before, so here are some practical, step-by-step fixes to get your app running:

1. Release Gradle File Locks & Clear Cached Distributions

The "exclusive access" error usually means a leftover Gradle process is holding a lock on the file. Let's kill those processes and clean up the problematic cache:

  • First, terminate all background Gradle processes:
    pkill -f gradle
    
  • Then delete the locked Gradle distribution directory:
    rm -rf /home/simo/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb/
    
  • Head back to your Flutter project root and run flutter run again—this will trigger a fresh download of the Gradle package.

2. Manually Download & Install the Gradle Package

Network latency or restrictions on Linux might be causing the timeout. Skip the auto-download by getting the package manually:

  1. Download the exact version mentioned in your error: gradle-5.6.2-all.zip
  2. Create the target directory if it doesn't exist:
    mkdir -p /home/simo/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb/
    
  3. Move the downloaded zip file into that directory.
  4. Run flutter run again—Gradle will now unpack the local file instead of downloading it.

3. Switch to Domestic Gradle Repositories

Foreign repositories are often slow from China. Update your project's Gradle config to use domestic mirrors (like Alibaba's):
Open your project's android/build.gradle file and replace the repositories blocks with:

buildscript {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
    }
    // Keep other existing buildscript content intact
}

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
    }
}

Save the file and re-run flutter run—this will speed up dependency downloads drastically.

4. Extend Gradle Timeout Limits

Sometimes the default timeout is too short for slow networks. Increase it in your project's android/gradle.properties file:
Add these lines at the bottom:

# Extend download timeout to 5 minutes (300,000 milliseconds)
android.gradle.plugin.download.timeout=300000
org.gradle.jvmargs=-Xmx1536M
org.gradle.daemon=true

This gives Gradle more time to complete downloads without timing out.

5. Fix Permissions for the .gradle Directory

Linux file permission issues can block Gradle from accessing its files. Ensure your user owns the .gradle directory:

sudo chown -R simo:simo /home/simo/.gradle/
chmod -R 755 /home/simo/.gradle/

This grants read/write access to your user, eliminating permission-related locks.

6. Restart Everything (Yes, Really!)

Occasionally, stale processes or cached state can cause weird issues. Fully close Android Studio, kill any leftover Java/Gradle processes, then restart your Linux Mint system. Open your project again and try flutter run once more.

If none of these work, you can also try updating Flutter to the latest stable release with flutter upgrade or double-checking that your Android SDK components are fully installed in Android Studio's SDK Manager.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.06 17:29:05