Flutter应用无法在真实设备或仿真器上运行

时间:2020-02-07 14:21:20

标签: android flutter dart android-emulator

我是Flutter的新手。我在运行Flutter项目时遇到了麻烦。

问题:

不适用于设备选择中显示的“ main.dart”配置enter image description here

运行项目后,控制台中显示以下异常。

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-a67792536ca236a971d0efbcfd7af4efb8f6c119.
     Required by:
         project :app
      > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
         > Could not get resource 'http://download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/flutter_embedding_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
            > Could not GET 'http://download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/flutter_embedding_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
               > Connect to download.flutter.io:80 [download.flutter.io/172.217.167.144] failed: Connection timed out: connect
      > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
         > Could not get resource 'http://download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/flutter_embedding_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
            > Could not GET 'http://download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/flutter_embedding_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
               > Connect to download.flutter.io:80 [download.flutter.io/172.217.167.144] failed: Connection timed out: connect
      > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
         > Could not get resource 'http://download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/flutter_embedding_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
            > Could not GET 'http://download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/flutter_embedding_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
               > Connect to download.flutter.io:80 [download.flutter.io/172.217.167.144] failed: Connection timed out: connect
   > Could not resolve io.flutter:armeabi_v7a_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
     Required by:
         project :app
      > Could not resolve io.flutter:armeabi_v7a_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
         > Could not get resource 'http://download.flutter.io/io/flutter/armeabi_v7a_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/armeabi_v7a_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
            > Could not GET 'http://download.flutter.io/io/flutter/armeabi_v7a_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/armeabi_v7a_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
               > Connect to download.flutter.io:80 [download.flutter.io/172.217.167.144] failed: Connection timed out: connect
      > Could not resolve io.flutter:armeabi_v7a_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
         > Could not get resource 'http://download.flutter.io/io/flutter/armeabi_v7a_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/armeabi_v7a_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
            > Could not GET 'http://download.flutter.io/io/flutter/armeabi_v7a_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/armeabi_v7a_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
               > Connect to download.flutter.io:80 [download.flutter.io/172.217.167.144] failed: Connection timed out: connect
      > Could not resolve io.flutter:armeabi_v7a_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
         > Could not get resource 'http://download.flutter.io/io/flutter/armeabi_v7a_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/armeabi_v7a_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
            > Could not GET 'http://download.flutter.io/io/flutter/armeabi_v7a_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/armeabi_v7a_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
               > Connect to download.flutter.io:80 [download.flutter.io/172.217.167.144] failed: Connection timed out: connect
   > Could not resolve io.flutter:x86_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
     Required by:
         project :app
      > Could not resolve io.flutter:x86_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
         > Could not get resource 'http://download.flutter.io/io/flutter/x86_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/x86_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
            > Could not GET 'http://download.flutter.io/io/flutter/x86_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/x86_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
               > Connect to download.flutter.io:80 [download.flutter.io/172.217.167.144] failed: Connection timed out: connect
      > Could not resolve io.flutter:x86_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
         > Could not get resource 'http://download.flutter.io/io/flutter/x86_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/x86_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
            > Could not GET 'http://download.flutter.io/io/flutter/x86_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/x86_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
               > Connect to download.flutter.io:80 [download.flutter.io/172.217.167.144] failed: Connection timed out: connect
      > Could not resolve io.flutter:x86_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
         > Could not get resource 'http://download.flutter.io/io/flutter/x86_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/x86_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
            > Could not GET 'http://download.flutter.io/io/flutter/x86_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/x86_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
               > Connect to download.flutter.io:80 [download.flutter.io/172.217.167.144] failed: Connection timed out: connect
   > Could not resolve io.flutter:x86_64_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
     Required by:
         project :app
      > Could not resolve io.flutter:x86_64_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
         > Could not get resource 'http://download.flutter.io/io/flutter/x86_64_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/x86_64_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
            > Could not GET 'http://download.flutter.io/io/flutter/x86_64_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/x86_64_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
               > Connect to download.flutter.io:80 [download.flutter.io/172.217.167.144] failed: Connection timed out: connect
      > Could not resolve io.flutter:x86_64_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
         > Could not get resource 'http://download.flutter.io/io/flutter/x86_64_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/x86_64_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
            > Could not GET 'http://download.flutter.io/io/flutter/x86_64_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/x86_64_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
               > Connect to download.flutter.io:80 [download.flutter.io/172.217.167.144] failed: Connection timed out: connect
      > Could not resolve io.flutter:x86_64_debug:1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.
         > Could not get resource 'http://download.flutter.io/io/flutter/x86_64_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/x86_64_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
            > Could not GET 'http://download.flutter.io/io/flutter/x86_64_debug/1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119/x86_64_debug-1.0.0-a67792536ca236a971d0efbcfd7af4efb8f6c119.pom'.
               > Connect to download.flutter.io:80 [download.flutter.io/172.217.167.144] 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 6m 45s
Finished with error: Gradle task assembleDebug failed with exit code 1


Flutter和Dart插件已安装最新版本。通过在CMD中运行Flutter Doctor显示一切正常。在这里,

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.12.13+hotfix.7, on Microsoft Windows
    [Version 10.0.18362.592], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version
    29.0.1)
[√] Android Studio (version 3.5)
[√] Connected device (1 available)

我不明白我在哪里犯错。如果您知道的话,请帮助我。

感谢您的帮助

3 个答案:

答案 0 :(得分:1)

尝试重新安装flutter的SDK。 我也面临着同样的问题。然后我重新安装了flutter SDK,一切都变得很完美。

答案 1 :(得分:0)

执行以下步骤:

  1. 转到项目结构> PROJECT> NOSDK
  2. 将NOSDK更改为最新的ANDROID API平台
  3. 当您开始做相同的事情

答案 2 :(得分:0)

可能是编译错误。这就是为什么控制台会说生成错误(带异常)的原因。如果您需要正确的答案,请提交代码以及问题