蒙国造博客

flutter run慢且提示Could not resolve all files for configuration ‘classpath’问题

编译的时候使用-v显示详情:

flutter run -v

可能会在这里卡住:

Could not resolve all files for configuration 'classpath'

有2中方法可以解决。

方法一 设置gradle代理

打开文件 ~/.gradle/gradle.properties,配置代理:

systemProp.https.proxyPort=10080
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=10080

方法二 使用国内源

修改文件一:android/build.gradle

//...
buildscript {
    repositories {
        //google()
        //jcenter()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/public' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
    }
}

allprojects {
    repositories {
        //google()
        //jcenter()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/public' }
    }
}
//...

修改文件二:flutter sdk目录,进入如下目录 flutter/⁨packages⁩/flutter_tools⁩/gradle/flutter.gradle 文件:

//...
buildscript {
     repositories {
         //google()
         //jcenter()
         maven { url 'https://maven.aliyun.com/repository/google' }
         maven { url 'https://maven.aliyun.com/repository/jcenter' }
         maven { url 'https://maven.aliyun.com/repository/public' }
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:3.5.3'
     }
 }
//...

退出移动版