运行 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.
- 手动下载 gradle 并解压。
- 找到
项目/android/gradlew.bat
打开。 - 找到
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
替换为set CLASSPATH=<path_to_downloaded_gardle>\gradle-4.6\lib\gradle-launcher-4.6.jar
。 - 找到
"%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%
。 - 重新执行
flutter run
。