当我尝试运行我的 Flutter 程序时,它会卡在“Running Gradle task 'assembleDebug”

Posted

技术标签:

【中文标题】当我尝试运行我的 Flutter 程序时,它会卡在“Running Gradle task \'assembleDebug”【英文标题】:when ever I try to run my Flutter program, it gets stuck at “Running Gradle task 'assembleDebug”当我尝试运行我的 Flutter 程序时,它会卡在“Running Gradle task 'assembleDebug” 【发布时间】:2020-10-04 20:28:45 【问题描述】:

每当我尝试在模拟器或真实设备上运行时,它都会卡在“Running Gradle task 'assembleDebug”,整个计算机就会死机并卡住,唯一的出路就是硬重启。

我使用的是华硕笔记本电脑(Windows 10),内存为 16GB。

flutter --version 给出:(当我尝试flutter upgrade 时,它给出相同的结果并说我有最新版本)

Flutter 1.20.0-1.0.pre.42 • channel master • https://github.com/flutter/flutter.git
Framework • revision 401690a64f (2 days ago) • 2020-06-12 19:45:48 -0700
Engine • revision 965fbbed17
Tools • Dart 2.9.0 (build 2.9.0-14.0.dev 2b917f5b6a)

当我运行 flutter doctor 时,我在终端中得到以下输出:UPDATED

   C:\Users\Lidor>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 1.20.0-1.0.pre.42, on Microsoft Windows [Version 10.0.18362.900], locale en-US)

[√] android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 4.0)
[√] IntelliJ IDEA Community Edition (version 2019.2)
[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

当我运行 flutter doctor -v 时,我得到这个输出:

C:\Users\Lidor>flutter doctor -v
[√] Flutter (Channel master, 1.20.0-1.0.pre.42, on Microsoft Windows [Version 10.0.18362.900], locale en-US)
    • Flutter version 1.20.0-1.0.pre.42 at D:\Study\P.Languages\Flutter\flutter_windows_v1.7.8+hotfix.4-stable\flutter
    • Framework revision 401690a64f (2 days ago), 2020-06-12 19:45:48 -0700
    • Engine revision 965fbbed17
    • Dart version 2.9.0 (build 2.9.0-14.0.dev 2b917f5b6a)

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at D:\Lidor\AppData\Local\Android\sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: D:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    X Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit
      https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.

[√] Android Studio (version 4.0)
    • Android Studio at D:\Program Files\Android\Android Studio
    • Flutter plugin version 46.0.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] IntelliJ IDEA Community Edition (version 2019.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.2
    • Flutter plugin version 38.1.4
    • Dart plugin version 192.5728.98

[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.

我还尝试运行flutter channel master,因为它建议here 以及所有here

【问题讨论】:

您是否更新了任何原生 android 文件(在 android 目录下)?添加了任何依赖项,改变了什么? 不,从运行顺利时起,一切都保持不变 这能回答你的问题吗? Flutter App stuck at "Running Gradle task 'assembleDebug'... " 不,@Nuts 已经提供了此链接,我们尝试过,但没有帮助 【参考方案1】:

发生这种情况的原因有很多:不接受 android-licenses、sdk/flutter 版本不兼容、Windows 防火墙等。

如果你还没有尝试过:

更新了文件 android/app/build.gradle

compileSdkVersion 29

运行: flutter clean

否则检查Flutter App stuck at "Running Gradle task 'assembleDebug'... "

或者如果你的Android license status unknown.

Android Studio installs without sdkmanager 取消选中 Hide Obsolete Packages,您将看到 Android SDK Tools (Obsolete) 26.1.1。 然后flutter doctor --android-licenses

【讨论】:

尝试运行 flutter clean 并尝试按照您提供的链接建议关闭防火墙,没有任何帮助 你试过链接中的其他方法吗?还是像禁用杀毒软件之类的? 禁用的防病毒软件不起作用,现在看看他们提供的其他解决方案 试试***.com/questions/60460429/…,别忘了运行flutter doctor --android-licenses y 你能更新你的颤振医生输出吗?里面写着Android license status unknown.

以上是关于当我尝试运行我的 Flutter 程序时,它会卡在“Running Gradle task 'assembleDebug”的主要内容,如果未能解决你的问题,请参考以下文章

flutter 卡在Running Gradle task 'assembleDebug'...

为啥futureBuilder有时会卡在进度加载器上?

Flutter,Visual Studio 代码项目卡在 Analyzing

带有 youtube dl 的不和谐机器人音乐不会卡在网页下载中

长汇编代码问题

Xcode 10.3 模拟器卡在 Apple 徽标上