Flutter 应用程序无法在真实设备或模拟器上运行

Posted

技术标签:

【中文标题】Flutter 应用程序无法在真实设备或模拟器上运行【英文标题】:Flutter app can't run on real device or emulator 【发布时间】:2020-05-23 16:45:00 【问题描述】:

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

问题:

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

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

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 中运行颤振医生显示一切正常。在这里,

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)

我不明白我错在哪里。如果你知道,请帮助我。

感谢您的帮助

【问题讨论】:

显示你的 main.dart 文件代码 默认代码通过创建 Flutter 应用程序提供。 【参考方案1】:

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

【讨论】:

【参考方案2】:

按照以下步骤操作:

    转到项目结构>项目>NOSDK 将 NOSDK 更改为最新的 ANDROID API 平台 然后去模块做同样的事情

【讨论】:

以上是关于Flutter 应用程序无法在真实设备或模拟器上运行的主要内容,如果未能解决你的问题,请参考以下文章

Flutter 应用程序无法在真实的 iOS 设备上运行(白屏)

iOS - 无法在真实设备 iPhone 11 中运行 Flutter 应用程序。iOS - 15.2,Xcode 13.2.1,它在模拟器中工作

Baqend 无法与模拟器或使用离子的真实设备一起使用

在flutter中从image_picker包中打开相机会导致真实设备上的应用程序崩溃,但在模拟器(android)中运行良好

将 Flutter 连接到真实设备中的 localhost 服务器

真实 iOS 设备上的 Flutter 错误:“未找到模块‘fluttertoast’”