当我尝试执行Flutter项目时,在“解决依赖关系”步骤中获得“ Error running Gradle”

时间:2019-10-06 04:23:25

标签: flutter android-gradle-plugin build.gradle

我怀疑代理设置没有正确设置,或者我可能写错了,请在这里帮助我。我正在公司网络下使用VPN。

下面的错误详细信息:

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "D:\flutter_workspace\flutter_app\android\gradlew.bat" exited abnormally:
Starting a Gradle Daemon (subsequent builds will be faster)


FAILURE: Build failed with an exception.

Finished with error: Please review your Gradle project setup in the android/ folder.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:3.2.1.
     Required by:
         project :
      > Could not resolve com.android.tools.build:gradle:3.2.1.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
            > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
               > Connect to dl.google.com:443 [dl.google.com/172.217.9.14] failed: Connection refused: connect

* 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 17s
  Command: D:\flutter_workspace\flutter_app\android\gradlew.bat app:properties

2 个答案:

答案 0 :(得分:0)

检查您的互联网连接,并确保其稳定。 Gradle试图连接到互联网以获取资源,但无法。 在这种情况下,我建议您关闭vpn,然后等待构建过程通过正常的Internet连接继续进行,然后在构建之后,您可以继续使用vpn

答案 1 :(得分:0)

最后,我终于确定了我所缺少的,我不得不按照developers.android.com的指示在gradle.properties文件中设置代理。由于某些原因,仅在Android Studio中设置代理无效。

更新的gradle.properties文件:

org.gradle.jvmargs=-Xmx1536M
systemProp.https.proxyHost=proxy.company.com
systemProp.https.proxyPort=80

PS:感谢@Taio的努力。我很感谢他们