You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio中Flutter Create Command执行失败,原因及新项目创建方法?

Hey there! Sorry to hear you're stuck with the "Flutter Create Command was Unsuccessful" error—especially since you already have a working Flutter project, so we know your core setup isn't completely broken. Let's walk through the most common causes and fixes to get you up and running with a new project.

Common Reasons for the Error

  • Corrupted or outdated Flutter SDK cache: Even if your existing project runs, the template files or cached dependencies needed to create a new project might be damaged.
  • Permission issues: If you're trying to create the project in a system-protected directory (like C:\Program Files on Windows or /System on Mac), Flutter won't have write access to generate project files.
  • Network problems: Creating a new project requires pulling template assets and dependencies from Flutter's servers. Unstable internet or regional restrictions can block these downloads.
  • IDE configuration glitches: If you're using Android Studio or VS Code, outdated plugins, incorrect Flutter SDK path settings, or cached IDE state might interfere with the flutter create command.
  • SDK version conflicts: Your existing project might work with an older Flutter version, but your current SDK has bugs or incompatibilities that break project creation.

Step-by-Step Fixes

  • Run flutter create directly in the terminal first: IDEs often hide detailed error messages. Open your terminal, navigate to a directory you own (e.g., cd ~/Documents/FlutterProjects on Mac, cd C:\Users\YourName\FlutterProjects on Windows), then run:
    flutter create my_new_project
    
    The terminal output will show exactly where the command fails—this is the fastest way to pinpoint the issue.
  • Repair Flutter's cached dependencies: Run these commands to clean and fix any corrupted cache:
    flutter clean
    flutter pub cache repair
    
    Try creating the project again after this completes.
  • Verify directory permissions: Make sure the folder you're creating the project in has full read/write access for your user account. Avoid system directories or folders that require admin rights. If you already tried in a restricted spot, move to a user-owned directory and retry.
  • Fix network issues (for regional users): If you're in a region where Flutter's default servers are inaccessible, configure the official Flutter China mirror:
    # Mac/Linux (add to your shell config file for permanent use)
    export PUB_HOSTED_URL=https://pub.flutter-io.cn
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
    
    # Windows Command Prompt
    set PUB_HOSTED_URL=https://pub.flutter-io.cn
    set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
    
    # Windows PowerShell
    $env:PUB_HOSTED_URL="https://pub.flutter-io.cn"
    $env:FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"
    
    Then run flutter create again.
  • Adjust your Flutter SDK version:
    • Update to the latest stable release:
      flutter upgrade
      
    • If the latest version is broken, downgrade to the version your existing project uses (replace 3.13.0 with your project's version):
      flutter downgrade 3.13.0
      
  • Reset your IDE configuration:
    • Check that your IDE's Flutter SDK path matches the one in your terminal (run which flutter on Mac/Linux or where flutter on Windows to confirm).
    • Update the Flutter and Dart plugins to their latest versions.
    • Restart your IDE to clear any cached state.
  • Reinstall Flutter as a last resort: If nothing else works, back up your existing projects, uninstall your current Flutter SDK, download the latest stable version, set up your environment variables again, and try creating a project.

内容的提问来源于stack exchange,提问作者Qasim Ali

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 15:32:40