原创

Flutter 开发 —Flutter 开发环境搭建

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/HeroGuo_JP/article/details/88621987
Flutter for Window 环境搭建请参考: https://blog.csdn.net/mo911108/article/details/88596342
Flutter for Mac 环境搭建:

参考

. [入门搭建环境](https://flutterchina.club/setup-macos/)
1、下载Flutter

官网下载: https://flutter.dev/docs/development/tools/sdk/archive?tab=macos#macos
github下载:https://github.com/flutter/flutter/releases

2、创建(或者修改).bash_profile
  • 在终端/Users/用户名/ 输入
open -e .bash_profile   // 如果打开不成功则会主动创建
  • 添加一下内容到 .bash_profile 文件
export PATH= /Users/用户名/flutter/bin:$PATH
  • 更新配置
source .bash_profile
3、运行flutter doctor 检查依赖安装
flutter doctor
4、解决错误
  • 注意先安装 Android Studio 打开https://developer.android.com/studio/index.html,并且下载安装了android studio。
    安装后最好运行一下android studio,好安装andriod sdk。运行好根据界面提示点下一步,如果没有sdk会提示安装,只要点就行了。记得查看下安装路径,一般路径都是在当前用户的Library文件夹里。
    安装好sdk后,可以把android studio关了。

看到[x]都是需要解决的错误

[!] Android toolchain - develop for Android devices (Android SDK 28.0.2)
    ✗ Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

根据错误提示运行

flutter doctor --android-licenses

然后根据提示一直y,y到结束为止。

*错误2

[!] iOS toolchain - develop for iOS devices
    ✗ 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
    ✗ libimobiledevice and ideviceinstaller are not installed. To install, run:
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    ✗ ios-deploy not installed. To install:
        brew install ios-deploy
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
        For more info, see https://flutter.io/platform-plugins
      To install:
        brew install cocoapods
        pod setup

我去App Store安装了xcode,安装好后根据之前的错误信息运行:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
brew install --HEAD libimobiledevice
// 然后
brew install ideviceinstaller
// 再然后
brew install ios-deploy
.........

根据提示 一步步安装。

  • 错误3
[!] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
    ✗ Missing Xcode dependency: Python module "six".
      Install via 'pip install six' or 'sudo easy_install six'.

按照提示输入’pip install six’ 或 ‘sudo easy_install six’。然后再运行doctor,我这里ios没有报错了。就剩错误3里的报错。

*错误4

[✓] Android Studio (version 3.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.

android studio里还少了两个插件。我们打开andriod studio。
1)、preferences–>plugins–>搜索flutter
2)、点击Search in reponsitories 搜索安装
有弹框提示要安装dart,同意。等安装好后重启andriod studio。
ps: 如果安装有其他应用 比如Intellij IDEA 怎需要安装 如上错误4 提示进行设置Intellij IDEA

注意如果误删了Android SDK,则每次安装的Android Studio的时候 都会提示SDK已经安装,从而无法完成Android 的安装。

我们需要完成一下步骤重新安装 SDK。在已经安装的Android Studio中右键,在bin 目录下idea.properties中添加 disable.android.first.run=true,再次运行Android Studio。则会提示安装SDK,根据提示进行安装。

展开阅读全文

没有更多推荐了,返回首页