【问题标题】:Flutter App stuck at "Running Gradle task 'assembleDebug'Flutter App 卡在“正在运行 Gradle 任务 'assembleDebug'
【发布时间】:2022-01-13 06:31:42
【问题描述】:

从 VScode 运行时,我的颤振应用程序总是卡在 running-gradle-task-assembledebug

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

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

颤振医生 -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!

创建了一个全新的颤振项目并执行 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 并重试。

【问题讨论】:

    标签: flutter


    【解决方案1】:

    这是由于你的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>\
    

    在此处粘贴并解压缩您下载的文件。

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

    【讨论】:

    猜你喜欢
    • 2023-03-09
    • 2020-04-18
    • 2021-04-21
    • 2020-12-05
    • 1970-01-01
    • 1970-01-01
    • 2021-02-19
    • 2023-02-24
    • 2020-05-25
    相关资源
    最近更新 更多