Flutter运行app失败 running gradle task assembleDebug

flutter环境搭建完成之后,首次运行项目,运行时会卡在Running Gradle task 'assembleDebug'..., 之后就会报这样的错!!

FAILURE: Build failed with an exception.
 
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.
     Required by:
         project :app
      > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/flutter_embedding_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.pom'.  
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/flutter_embedding_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.pom'.        
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/172.217.27.144] failed: Connection timed out: connect
      > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.       
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/flutter_embedding_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.pom'.  
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/flutter_embedding_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.pom'.        
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/34.64.4.80] failed: Connection timed out: connect
      > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/flutter_embedding_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.pom'.  
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/flutter_embedding_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.pom'.        
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/34.64.4.80] failed: Connection timed out: connect
   > Could not resolve io.flutter:x86_debug:1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.
     Required by:
         project :app
      > Could not resolve io.flutter:x86_debug:1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/x86_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.pom'.
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/x86_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.pom'.
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/172.217.27.144] failed: Connection timed out: connect
      > Could not resolve io.flutter:x86_debug:1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/x86_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.pom'.
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/x86_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.pom'.
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/34.64.4.80] failed: Connection timed out: connect
      > Could not resolve io.flutter:x86_debug:1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/x86_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.pom'.
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/x86_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.pom'.
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/34.64.4.80] failed: Connection timed out: 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 7m 50s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                       472.2s (!)
Exception: Gradle task assembleDebug failed with exit code 1

解决方案

查阅发现是 因为Gradle的Maven仓库在国外, 可以使用阿里云的镜像地址。

1.修改项目中android/build.gradle文件

Flutter运行app失败 running gradle task assembleDebug_第1张图片

2. 修改flutter sdk安装目录下的 packages/flutter_tools/gradle/flutter.gradle

Flutter运行app失败 running gradle task assembleDebug_第2张图片

你可能感兴趣的:(Flutter)