Flutter调试报错Could not download解决不能下载jar包问题

遇到这个问题所以记录下来,省得再次百度
因为不能访问Google,所以下载不了jar包
解决办法:

  • 更改Gradle仓库地址,使用阿里云加速:修改Flutter SDK安装目录下的\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 'http://maven.aliyun.com/nexus/content/groups/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
    }
}
  • 配置项目内的build.gradle文件


    20190809092234612.png
buildscript {
    ext.kotlin_version = '1.2.71'
    repositories {
        // google()
        // jcenter()
        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' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        // google()
        // jcenter()
        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' }
    }
}

然后就可以运行调试了

你可能感兴趣的:(Flutter调试报错Could not download解决不能下载jar包问题)