Flutter 应用程序卡在 "Running Gradle task ' assembleDebug'

标签 flutter

从 VScode 运行时,我的 flutter 应用程序始终卡在 running-gradle-task-assembledebug

当我在命令提示符下运行 flutter run -v 时,它可以工作,但不能从 VSCode 运行。这个问题似乎从上周就出现了。 尝试过 ./gradlew clean 和 ./gradlew clean 构建,这有时有效并且从 vscode 构建

删除并创建了一个新的模拟器设备,并在线尝试了许多建议

flutter doctor -v 的输出

[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.19044.1415], locale en-US)
    • Flutter version 2.8.1 at E:\Flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (4 weeks ago), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at E:\sdk\Android
    • Platform android-31, build-tools 30.0.2
    • ANDROID_SDK_ROOT = E:\sdk\Android
    • Java binary at: F:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 2020.3)
    • Android Studio at F:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] Connected device (3 available)
    • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86    • Android 9 (API 28) (emulator)
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 97.0.4692.71
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 96.0.1054.62

• No issues found!

创建了一个全新的 flutter 项目并进行了 gradlew clean 并得到了以下 gradlew clean --warning-mode all 的消息

> Configure project :app
Adding a Configuration as a dependency is a confusing behavior which isn't recommended. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. If you're interested in inheriting the dependencies from the Configuration you are adding, you should use Configuration#extendsFrom instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.artifacts.Configuration.html#org.gradle.api.artifacts.Configuration:extendsFrom(org.gradle.api.artifacts.Configuration[]) for more details.
        at build_59yj46qtreisbbowxqfuhj29p$_run_closure3.doCall(D:\MobileDevelopment\GitRepo\jigsaw\android\build.gradle:26)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.destinationDir property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the destinationDirectory property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:destinationDir for more details.
        at FlutterPlugin$_addFlutterTasks_closure20$_closure44.doCall(E:\Flutter\packages\flutter_tools\gradle\flutter.gradle:833)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.archiveName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveFileName property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:archiveName for more details.
        at FlutterPlugin$_addFlutterTasks_closure20$_closure44.doCall(E:\Flutter\packages\flutter_tools\gradle\flutter.gradle:834)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

BUILD SUCCESSFUL in 2s
2 actionable tasks: 2 up-to-date

运行 gradlew build 会给出

> Task :app:stripDebugDebugSymbols
Unable to strip the following libraries, packaging them as they are: libflutter.so.

> Task :app:stripProfileDebugSymbols
Unable to strip the following libraries, packaging them as they are: libapp.so, libflutter.so, libvmservice_snapshot.so

> Task :app:lint FAILED
Ran lint on variant debug: 3 issues found
Ran lint on variant release: 3 issues found
Ran lint on variant profile: 3 issues found
Wrote HTML report to file:///D:/MobileDevelopment/GitRepo/jigsaw/build/app/reports/lint-results.html
Wrote XML report to file:///D:/MobileDevelopment/GitRepo/jigsaw/build/app/reports/lint-results.xml

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:lint'.
> Lint found errors in the project; aborting build.

  Fix the issues identified by lint, or add the following to your build script to proceed with errors:
  ...
  android {
      lintOptions {
          abortOnError false
      }
  }
  ...
  Errors found:

  D:\MobileDevelopment\GitRepo\jigsaw\android\app\src\main\AndroidManifest.xml:5: Error: Class referenced in the manifest, com.example.jigsaw.${applicationName}, was not found in the project or the libraries [MissingClass]
          android:name="${applicationName}"
                        ~~~~~~~~~~~~~~~~~~



* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2m 26s
94 actionable tasks: 90 executed, 4 up-to-date

从google官方文档重新下载了flutter 2.8 sdk,里面也有dart并重试。

最佳答案

这是由于你的gradle正在下载它的版本,但有时下载速度太慢而无法下载,你可以修复它:

首先检查项目根目录中的 gradle 版本:

<project name> > android > gradle > wrapper > gradle-wrapper.properties

并检查 distributionUrl ,您将看到项目中正在使用哪个 gradle 版本并正在下载,因此您应该在此链接 https://services.gradle.org/distributions/ 中下载该版本。

下载后,复制并转到此目录:

C:\Users\<user name>\.gradle\wrapper\dists\gradle <your version>\<a file with weird name>\

将下载的文件粘贴并解压到此处。

每当我对你抱有希望时,它都对我有用。 如果有任何问题请告诉我。

关于Flutter 应用程序卡在 "Running Gradle task ' assembleDebug',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70692313/

相关文章:

flutter - 如何在 Flutter 中添加带有图标的按钮

flutter - 互联网在我的 android 模拟器上不起作用?

flutter - 如何在 Flutter 中固定卡片宽度?

Flutter Provider select - 如何处理复杂的返回类型,如列表或 map

flutter - 为什么父级StatefulWidget中的setState不会更新子级StatefulWidget

flutter - 如何切换到横向

dart - Flutter Dart : Future. wait() 通过引用传递值?

dart - flutter 相机插件

flutter - 如何在GridView.builder中设置容器的固定高度?不应依赖于 childAspectRatio

flutter - android 后退按钮不会调用 WillPopScope 的 onWillPop