无法运行“ Pub Get”并且无法构建Flutter项目

时间:2020-06-28 22:08:25

标签: android-studio flutter gradle

在Android Studio上,我克隆了this flutter project。当提示是否要为下载的源创建项目时,单击“否”。然后单击“打开现有项目”,然后选择刚刚下载的项目。

Android Studio告诉我“ Pub get尚未运行”。所以我点击“获取依赖项”:

C:\src\flutter\flutter\bin\flutter.bat --no-color pub get
Running "flutter pub get" in dicee-flutter2...                      3,0s
Process finished with exit code 0

此后,代码中的突出显示已得到纠正,因此我想项目现在可以识别抖动了。但是“ Pub get尚未运行”提示永远不会消失。

然后我运行我的项目,以便在虚拟设备中看到它,但是出现以下错误:

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
--output directory is required for assemble.

FAILURE: Build failed with an exception.

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

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\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 2s
Exception: Gradle task assembleDebug failed with exit code 1

Flutter Doctor的输出为:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 1.20.0-3.0.pre.78, on Microsoft Windows [versão 10.0.18362.356], locale pt-BR)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
[√] Android Studio (version 4.0)
[√] Connected device (1 available)

• No issues found!

如何解决此问题,以便我可以在虚拟设备上看到项目并停止获取“ Pub get has not been run”提示?

1 个答案:

答案 0 :(得分:0)

AS中有一项设置可以设置输出目录。从内存中它在文件中|项目设置菜单。

这可能是发布获取问题的另一个问题。

您只需从项目根目录中的cli运行flutter pub get。