无法在Flutter应用程序上构建“任务组装调试失败,退出代码为1”

时间:2020-05-07 04:14:23

标签: android android-studio flutter dart flutter-dependencies

我在Android Studio上使用标准的flutter应用程序,当我无法执行flutter pub get时,当我执行flutter run时,我会收到此异常

FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 882

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* 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 17s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        18,2s
Exception: Gradle task assembleDebug failed with exit code 1

我已经尝试强制升级并轻拂干净

Flutter Doctor -v

[√] Flutter (Channel stable, v1.17.0, on Windows, locale pt-BR)
    • Flutter version 1.17.0 at C:\src\flutter
    • Framework revision e6b34c2b5c (4 days ago), 2020-05-02 11:39:18 -0700
    • Engine revision 540786dd51
    • Dart version 2.8.1


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at C:\Users\kaduc\AppData\Local\Android\sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio1
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[!] IntelliJ IDEA Community Edition (version 2019.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.3
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[√] VS Code (version 1.44.2)
    • VS Code at C:\Users\kaduc\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.10.1

[√] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

! Doctor found issues in 1 category.

我已经卸载了Android Studio IDE并重新安装,然后尝试重新安装Java JDK,但是没有机会不知道该怎么办才能解决此问题。

1 个答案:

答案 0 :(得分:4)

问题:
flutter和dart插件未正确下载或未使用Android Studio正确配置。
解决方案:
有一种解决方法。您可以按照以下步骤在android studio中安装/重新安装Flutter&Dart插件。
1)打开Android Studio。
2)打开插件首选项(“文件”>“设置”>“ Windows”和“ Linux”上的插件,或“首选项”>“ macOS”上的插件)。
3)选择浏览存储库,选择Flutter插件,然后单击安装。
4)提示安装Dart插件时,单击“是”。
5)出现提示时,单击“重新启动”。
6)运行命令:sudo chown -R YOUR_USERNAME YOUR_FLUTTER_DIRECTORY
示例:sudo chown -R sanketvekariya /opt/flutter
一些参考文献:
https://github.com/flutter/flutter/issues/21881
https://github.com/flutter/flutter/issues/45528
Flutter plugin not installed error;. When running flutter doctor
仅供参考:
我之前也遇到过同样的问题,并通过上述步骤解决了。希望您能尽快解决这个问题。:)