android - 尽管设置了代理明确,但在代理后面运行的颤动无法下载 gradle 依赖项
问题描述
Flutter 在获取依赖项时应该使用代理环境变量,但它没有这样做。
> $env:http_proxy="127.0.0.1:8090"
> $env:https_proxy="127.0.0.1:8090"
> $env:NO_PROXY="localhost,127.0.0.1"
> flutter create app
> cd app
> flutter run
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.5.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.pom
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.jar
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
我知道使用 VPN 也是一种选择。但我更喜欢使用代理。操作系统:Windows 10
解决方案
如果你在代理后面,你必须再次明确地为 gradle 设置代理,这意味着gradle不尊重环境变量,这有点烦人。不管怎样,你去吧。
在您的主文件夹中的目录gradle.properties
下创建一个文件。.gradle
code ~/.gradle/gradle.properties
将以下内容粘贴到其中
systemProp.http.proxyHost={ProxyIP}
systemProp.http.proxyPort={ProxyPort}
systemProp.http.nonProxyHosts=*.jitpack.io, *.maven.org
systemProp.https.proxyHost={ProxyIP}
systemProp.https.proxyPort={ProxyPort}
systemProp.https.nonProxyHosts=*.jitpack.io, *.maven.org
就我而言maven.org
,jitpack.io
可以直接浏览域。
并且不要忘记flutter clean
之前运行flutter run
。看看发生了什么运行flutter run -v
推荐阅读
- python - 如何从命令行运行不同的python函数
- c++ - Armadillo equivalent to A(find(A<0)) = 0
- oop - (巨型)应用程序真的只包含一个 Timer 对象吗?
- javascript - 检查 null 的条件语句不起作用
- c++ - Reversing a text read from console
- lumen - 接受对象的自定义过滤器 - lighthouse-php
- python - 在 NumPy 中将具有不同维度的“N”个 2D 数组连接到一个 3D 数组中
- arrays - 如何从我在 MongoDB 中的集合中的三个现有字段创建数组或嵌入文档
- java - 插入数组时 H2 数据库中的 SQL 语法错误
- jupyter-notebook - Google Colab中jupyter笔记本的所有单元格输出消失