Android Studio在创建新的Flutter项目时陷入困境

时间:2018-03-06 18:59:44

标签: android-studio flutter

我在Windows上安装了Flutter,并使用颤动医生检查了一切正常。 我导入了Flutter插件。

现在,当我尝试通过Anroid Studio创建一个新的Flutter应用程序时,它永远不会结束。 我得到了“创建Flutter项目”,就是这样。

消息区域包含“”C:\ Program Files \ Flutter \ flutter \ bin \ flutter.bat“--no-color create --template app --description”一个新的Flutter应用程序。“ - orok anykey。 co.il flutter_app4“ 它似乎停留在“建筑符号......”上。

我甚至将它留在了一夜之间,希望它能完成。

最后我必须杀了它。

编辑: 看来我的flutter.bat文件正在循环播放。 我试过扑了一下医生(回声一下),这就是我得到的。 最后一部分永远循环。

C:\Users\user>flutter doctor

C:\Users\user>REM Copyright 2017 The Chromium Authors. All rights reserved.

C:\Users\user>REM Use of this source code is governed by a BSD-style license that can be

C:\Users\user>REM found in the LICENSE file.

C:\Users\user>REM ---------------------------------- NOTE ----------------------------------

C:\Users\user>REM

C:\Users\user>REM Please keep the logic in this file consistent with the logic in the

C:\Users\user>REM `flutter` script in the same directory to ensure that Flutter continues to

C:\Users\user>REM work across all platforms!

C:\Users\user>REM

C:\Users\user>REM --------------------------------------------------------------------------

C:\Users\user>SETLOCAL ENABLEDELAYEDEXPANSION

C:\Users\user>FOR %i IN ("C:\Program Files\Flutter\flutter\bin\..") DO SET FLUTTER_ROOT=%~fi

C:\Users\user>SET FLUTTER_ROOT=C:\Program Files\Flutter\flutter

C:\Users\user>SET flutter_tools_dir=C:\Program Files\Flutter\flutter\packages\flutter_tools

C:\Users\user>SET cache_dir=C:\Program Files\Flutter\flutter\bin\cache

C:\Users\user>SET snapshot_path=C:\Program Files\Flutter\flutter\bin\cache\flutter_tools.snapshot

C:\Users\user>SET stamp_path=C:\Program Files\Flutter\flutter\bin\cache\flutter_tools.stamp

C:\Users\user>SET script_path=C:\Program Files\Flutter\flutter\packages\flutter_tools\bin\flutter_tools.dart

C:\Users\user>SET dart_sdk_path=C:\Program Files\Flutter\flutter\bin\cache\dart-sdk

C:\Users\user>SET engine_stamp=C:\Program Files\Flutter\flutter\bin\cache\engine-dart-sdk.stamp

C:\Users\user>SET engine_version_path=C:\Program Files\Flutter\flutter\bin\internal\engine.version

C:\Users\user>SET pub_cache_path=C:\Program Files\Flutter\flutter\.pub-cache

C:\Users\user>SET dart=C:\Program Files\Flutter\flutter\bin\cache\dart-sdk\bin\dart.exe

C:\Users\user>SET pub=C:\Program Files\Flutter\flutter\bin\cache\dart-sdk\bin\pub.bat

C:\Users\user>REM If available, add location of bundled mingit to PATH

C:\Users\user>SET mingit_path=C:\Program Files\Flutter\flutter\bin\mingit\cmd

C:\Users\user>IF EXIST "C:\Program Files\Flutter\flutter\bin\mingit\cmd" SET PATH=C:\Program Files\Git\cmd;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Android\android-sdk\platform-tools;C:\Program Files\Calibre2\;C:\Program Files\Java\jre7\bin\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Git\cmd;c:\Program Files (x86)\PuTTY;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\rexx.org\Regina;C:\Program Files\Git\cmd;C:\Users\user\AppData\Local\Microsoft\WindowsApps;C:\Users\user\AppData\Roaming\Dashlane\4.6.8.26847\bin\Firefox_Extension\{442718d9-475e-452a-b3e1-fb1ee16b8e9f}\components;C:\Program Files\Flutter\flutter\bin;;C:\Program Files\Flutter\flutter\bin\mingit\cmd

C:\Users\user>REM Test if Git is available on the Host

C:\Users\user>where /q git   || ECHO Error: Unable to find git in your PATH.   && EXIT /B 1

C:\Users\user>REM  Test if the flutter directory is a git clone, otherwise git rev-parse HEAD would fail

C:\Users\user>IF NOT EXIST "C:\Program Files\Flutter\flutter\.git" (
ECHO Error: The Flutter directory is not a clone of the GitHub project.
 EXIT /B 1
)

C:\Users\user>REM Ensure that bin/cache exists.

C:\Users\user>IF NOT EXIST "C:\Program Files\Flutter\flutter\bin\cache" MKDIR "C:\Program Files\Flutter\flutter\bin\cache"

C:\Users\user>REM To debug the tool, you can uncomment the following lines to enable checked mode and set an observatory port:

C:\Users\user>REM SET FLUTTER_TOOL_ARGS="--checked "

C:\Users\user>REM SET FLUTTER_TOOL_ARGS=" --observe=65432"

C:\Users\user>(
REM "3" is now stderr because of "2>NUL".
 CALL :subroutine doctor   2>&3 9>"C:\Program Files\Flutter\flutter\bin\cache\flutter.bat.lock"  || GOTO acquire_lock
) 2>NUL

C:\Users\user>(
REM "3" is now stderr because of "2>NUL".
 CALL :subroutine doctor   2>&3 9>"C:\Program Files\Flutter\flutter\bin\cache\flutter.bat.lock"  || GOTO acquire_lock
) 2>NUL

第二次编辑:

“颤动医生-v”的输出

    [v] Flutter (Channel beta, v0.1.5, on Microsoft Windows [Version 10.0.16299.248], locale en-US)
    • Flutter version 0.1.5 at C:\Program Files\flutter
    • Framework revision 3ea4d06340 (13 days ago), 2018-02-22 11:12:39 -0800
    • Engine revision ead227f118
    • Dart version 2.0.0-dev.28.0.flutter-0b4f01f759

[v] Android toolchain - develop for Android devices (Android SDK 26.0.2)
    • Android SDK at C:\Users\user\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-26, build-tools 26.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[v] Android Studio (version 3.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[v] Connected devices (1 available)
    • Nexus 10 • R32F201H9ME • android-arm • Android 5.1.1 (API 22)

• No issues found!

12 个答案:

答案 0 :(得分:2)

这很可能是因为你将Flutter放在Program Files中,这需要管理员权限才能写入其缓存文件。

我有一个PR Open会导致更友好的错误,但我建议将Flutter移到非管理员用户可以写入的文件夹中。

答案 1 :(得分:2)

选择选项后,当出现“正在创建新的 Flutter 项目”时,结束 Android Studio 进程并重新运行它然后 - 而不是创建项目 - 选择 打开项目并选择您之前创建的项目文件夹。

答案 2 :(得分:1)

有同样的问题。

只需在管理员模式下运行Android Studio / IntelliJ即可。它有效。

答案 3 :(得分:1)

对于Windows 10,这里有几种解决方案,我在这里与我分享正在解决的问题。

1。。“设置”中存在“设置Flutter SDK路径”。 Settings > Languages & Settings > Flutter > Flutter SDK Path

2。。以管理员模式

运行Android Studio / IntelliJ。

3。。您的项目位置路径文件夹名称为有效的Dart包名称

答案 4 :(得分:1)

就我而言,这就是问题所在-我选中了离线创建项目复选框。请确保未选中此复选框。

enter image description here

答案 5 :(得分:0)

很久以前,我对同样的问题感到震惊。经过很多磕磕绊绊之后,我做对了。 首先删除以前克隆的flutter文件并在用户文件夹中安装git。喜欢 C:\users\username\

克隆在你的git目录中颤动,设置路径 C:\users\username\git\flutter\bin

现在使用命令flutter doctor 如果您有android studio和intellij IDE,请在两者中安装flutter插件,然后创建一个新项目。

你们都准备好了

答案 6 :(得分:0)

我在MacOS 10.13.4上遇到了同样的问题,当在Android Studio(3.1)上创建一个新的Flutter项目时,IDE卡住了,显示了短语"构建符号"在窗户的底部。

在cli上运行命令flutter run时,消息为:startup lock

然后我从flutter sdk缓存中删除了锁: rm ./bin/cache/lockfile

这是https://github.com/flutter/flutter/issues/7768

报告的问题

答案 7 :(得分:0)

我在Windows 10上遇到了同样的问题。确保Flutter SDK的路径出现在“ AS设置”中。设置>语言和设置> Flutter> Flutter SDK路径

答案 8 :(得分:0)

我已禁用了防病毒(快速修复),并以管理员身份运行CMD并运行“ flutter ”命令。工作正常然后检查“ 扑打医生”命令,它也可以正常工作。

然后以管理员模式启动AS并创建flutter应用程序,它现在开始工作。

答案 9 :(得分:0)

对我来说,这在Windows 10中有效:

  • Flutter SDK的位置:保留在c:\ Users <用户名> \ AppData \ Local
  • 项目位置:保存在c:\ Users <用户名> \ AppData \ Local
  • 以管理员模式启动Android Studio:这不是必需的,它在没有管理员权限的情况下可以正常工作
  • 在创建新的Flutter项目时:离线创建项目(选择此选项)(同一篇帖子中的另一个答案是带有屏幕截图的,请不要选择它,但对我而言,只有在选择了此选项后,它才起作用选项)

创建项目花费了多少时间? 2分钟

答案 10 :(得分:0)

在windows中尝试以管理员身份运行android studio并创建新的flutter项目

答案 11 :(得分:-2)

将计算机连接到Internet,然后尝试创建项目 这样可以解决问题