Flutter 常见错误

运行 flutter run 报错:

Initializing gradle...                                          |
Oops; flutter has exited unexpectedly: "Exit code 1 from: xx\flutter-project\android\gradlew.bat --v:
Exception in thread "main" java.lang.RuntimeException: Timeout of 120000 reached waiting for exclusive acccess to file: C:\Users\...\.gradle\wrapper\dists\gradle-4.1-all\bzyivzo6n839fup2jbap0tjew\gradle-4.1-lall.zip
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:61)
        at org.gradle.wrapper.Install.createDist(Install.java:48)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)".
Sending crash report to Google.
Failed to send crash report due to a network error: SocketException: OS Error: 信号灯超时时间已到
, errno = 121, address = clients2.google.com, port = 61269
Crash report written to  xx\flutter-project\flutter_01.log;
please let us know at https://github.com/flutter/flutter/issues.
  1. 手动下载 gradle 并解压。
  2. 找到项目/android/gradlew.bat打开。
  3. 找到set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar替换为set CLASSPATH=<path_to_downloaded_gardle>\gradle-4.6\lib\gradle-launcher-4.6.jar
  4. 找到"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%替换为"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.launcher.GradleMain %CMD_LINE_ARGS%
  5. 重新执行flutter run
    原文作者:soojade
    原文地址: https://www.jianshu.com/p/b63f51544902
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞