Android Studio stuck when creating new Flutter pro

2020-04-04 13:14发布

I have installed Flutter on Windows and checked all is ok using flutter doctor. I imported the Flutter plugin.

Now, when I try to create a new Flutter app via Anroid Studio it never ends. I get "Creating Flutter Project" and that's it.

The message area contains ""C:\Program Files\Flutter\flutter\bin\flutter.bat" --no-color create --template app --description "A new Flutter application." --org anykey.co.il flutter_app4" It seems to be stuck on "Building symbols...".

I even left it on overnight hoping it would finish.

In the end I have to kill it.

Edit: It seems that my flutter.bat file is looping. I tried flutter doctor (who echo set to on) and this is what I get. The last part loops forever.

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

Second edit:

Output of "flutter doctor -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!

7条回答
女痞
2楼-- · 2020-04-04 13:24

I was struck with the same problem a while back. After a lot of stumbling I got it right. First of all delete your previous cloned flutter files and install git in your user folder. Like C:\users\username\

Clone flutter in your git directory,set the path C:\users\username\git\flutter\bin

Now use the command flutter doctor If you have android studio and intellij IDE, install flutter plugins in both of them and now create a new project.

You are all set to go

查看更多
孤傲高冷的网名
3楼-- · 2020-04-04 13:24

I have disabled the Antivirus(Quick Heal), and run the CMD as administrator and run "flutter" command. It's working. Then checked the "flutter doctor" command, It's also working fine.

Then started the AS as administrator mode and create the flutter app and it's started working now.

查看更多
老娘就宠你
4楼-- · 2020-04-04 13:27

This is likely because you've put Flutter in Program Files which requires admin permissions to be able to write its cache files.

I've got a PR Open that should result in a more friendly error, but I'd recommend moving Flutter away to a folder that non-Admin users can write to.

查看更多
We Are One
5楼-- · 2020-04-04 13:31

For windows 10 there is couple of solution here, I am sharing with here which is working for me.

1. Set Flutter SDK path is present in AS Settings . Settings > Languages & Settings > Flutter > Flutter SDK Path

2. Run Android Studio/IntelliJ in administrator mode

3. Your project location path folder name is valid Dart package name.

查看更多
趁早两清
6楼-- · 2020-04-04 13:33

I had the same issue on MacOS 10.13.4, when creating a new Flutter project on the Android Studio (3.1), the IDE got stuck, showing the phrase "building symbols" on the bottom of the window.

When running the command flutter run on the cli, the message was: startup lock.

then I removed the lock from the flutter sdk cache: rm ./bin/cache/lockfile

this is an issue reported on https://github.com/flutter/flutter/issues/7768

查看更多
够拽才男人
7楼-- · 2020-04-04 13:37

Had the same issue.

Just run Android Studio/IntelliJ in administrator mode. It works.

查看更多
登录 后发表回答