1、Connect to 127.0.0.1:1087 [/127.0.0.1] failed: Connection refused (Connection refused)

控制台显示如下报错信息:

  1. Launching lib/main.dart on sdk gphone x86 arm in debug mode...
  2. Running Gradle task 'assembleDebug'...
  3. FAILURE: Build failed with an exception.
  4. * What went wrong:
  5. A problem occurred configuring root project 'android'.
  6. > Could not resolve all artifacts for configuration ':classpath'.
  7. > Could not resolve com.android.tools.build:gradle:3.2.1.
  8. Required by:
  9. project :
  10. > Could not resolve com.android.tools.build:gradle:3.2.1.
  11. > Could not get resource 'https://maven.aliyun.com/repository/google/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
  12. > Could not HEAD 'https://maven.aliyun.com/repository/google/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
  13. > Connect to 127.0.0.1:1087 [/127.0.0.1] failed: Connection refused (Connection refused)
  14. > Could not resolve com.android.tools.build:gradle:3.2.1.
  15. > Could not get resource 'https://maven.aliyun.com/repository/jcenter/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
  16. > Could not HEAD 'https://maven.aliyun.com/repository/jcenter/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
  17. > Connect to 127.0.0.1:1087 [/127.0.0.1] failed: Connection refused (Connection refused)
  18. > Could not resolve com.android.tools.build:gradle:3.2.1.
  19. > Could not get resource 'http://maven.aliyun.com/nexus/content/groups/public/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
  20. > Could not HEAD 'http://maven.aliyun.com/nexus/content/groups/public/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
  21. > Connect to 127.0.0.1:1087 [/127.0.0.1] failed: Connection refused (Connection refused)
  22. * Try:
  23. 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.
  24. * Get more help at https://help.gradle.org
  25. BUILD FAILED in 9s
  26. Exception: Gradle task assembleDebug failed with exit code 1

需要删除项目根目录 gradle.properties 内的代理配置

  1. systemProp.https.proxyPort=1080
  2. systemProp.http.proxyHost=127.0.0.1
  3. systemProp.https.proxyHost=127.0.0.1
  4. systemProp.http.proxyPort=1080

如果还没解决,需要我们去删除全局配置里代理配置
Windows

  1. C:\Users\Administrator.gradle\gradle.properties

Mac

  1. open /Users/你的用户目录/.gradle/gradle.properties