flutter安装踩坑记录

-------终端输出错误,及解决办法----------

1、apple@XXX ~ % source ~/.bash_profile

/Users/apple/.bash_profile:5: bad assignment

原因:  .bash_proflie 文件中不能有空格

2、apple@XXX Downloads ~ % flutter doctor

zsh: command not found: flutter

原因: 目录不正常,应该在根目录执行

3、查看flutter插件是否安装成功

apple@XXX ~ % flutter doctor

zsh: command not found: flutter  

原因:  可能是.bash_profile保存失败,导致查询不到flutter插件

4、检查 flutter 插件是否存在

apple@XXX ~ % flutter doctor

Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.4 19E287, locale

    zh-Hans-CN)

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)

    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor

      --android-licenses

原因:  Android 需要更新  在根文件目录执行:flutter doctor --android-licenses  一路输入 y 即可 

apple@XXX ~ % flutter doctor --android-licenses

Accept? (y/N): y

All SDK package licenses accepted

[!] Xcode - develop for iOS and macOS

    ✗ Xcode installation is incomplete; a full installation is necessary for iOS

      development.

      Download at: https://developer.apple.com/xcode/download/

      Or install Xcode via the App Store.

      Once installed, run:

        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

        sudo xcodebuild -runFirstLaunch

解决办法:  在文件根目录执行 两句 命令:

1、sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

apple@XXX ~ % sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Password:(输入电脑解锁密码)

2、sudo xcodebuild -runFirstLaunch

apple@XXX ~ % sudo xcodebuild -runFirstLaunch

[✓] Android Studio (version 3.3)

[!] Connected device

    ! No devices available

原因:  找不到可运行的设备 ,

解决办法: 1、手机连接电脑

2、打开模拟器simulator 

3、运行android模拟器

! Doctor found issues in 3 categories.

原因:  插件有问题,安装提示一一解决即可

5、新建项目运行:1)flutter packages 2)get flutter pub get

如果长时间Waiting for another flutter command to release the startup lock...

解决方法一、

1、关闭Android Studio或VSCode

2、打开flutter安装目录/bin/cache

3、删除lockfile文件

4、在终端再执行flutter相关命令.一般就可以解决

方法二、

查看镜像是否可以打开,如果有镜像打开404 则切换镜像

flutter社区经营的镜像站点地址: https://flutter.dev/community/china

1、执行替换镜像命令:

export PUB_HOSTED_URL=https://dart-pub.mirrors.sjtug.sjtu.edu.cn/

export FLUTTER_STORAGE_BASE_URL=https://mirrors.sjtug.sjtu.edu.cn/

2、重新加载.bash文件(!!!重新绑定镜像后一定要执行这句)

source ~/.bash_profile

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。