美文网首页
Flutter初体验之安装Flutter(补)

Flutter初体验之安装Flutter(补)

作者: GIndoc | 来源:发表于2019-03-14 11:41 被阅读0次

    这篇文章本来是不打算发的,因为网上教程太多了,而且都大同小异。今天在做笔记时突然想起来,觉得还是发出来,希望能对其他遇到相同问题的人有所帮助。

    获取Flutter SDK

    第一步

    git clone -b beta https://github.com/flutter/flutter.git
    
    export PATH= PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin:$PATH
    export ANDROID_HOME="/Users/用户名/Documents/android_sdk" //android sdk目录,替换为你自己的即可
    export PATH=${PATH}:${ANDROID_HOME}/tools
    export PATH=${PATH}:${ANDROID_HOME}/platform-tools
    
    export PUB_HOSTED_URL=https://pub.flutter-io.cn //国内用户需要设置
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn //国内用户需要设置
    

    注意:__ PATH_TO_FLUTTER_GIT_DIRECTORY __为你flutter的路径,比如“~/document/code”

    第二步

    • 运行 source .profile 刷新当前终端窗口.
    • 执行echo $PATH,查看环境变量是否添加成功

    第三步(运行Flutter)

    flutter doctor

    注意:这里可能会提示有错,比如:
    1、Android SDK 路径有误,或者ANDROID_HOME环境变量没设置

    [-] Android toolchain - develop for Android devices
        • Android SDK at /Users/obiwan/Library/Android/sdk
        ✗ Android SDK is missing command line tools; download from https://goo.gl/XxQghQ
        • Try re-installing or updating your Android SDK,
          visit https://flutter.io/setup/#android-setup for detailed instructions.
    

    2、报 Downloaded executables cannot execute on host. 错误,同时也给出了解决方案

    1、在Debian/Ubantu/Mint上,执行 sudo apt-get install lib32stdc++6
    2、在Fedora上,执行 dnf install libstdc++.i686
    3、在Arch上,执行 pacman -S lib32-libstdc++5
    

    查了一下,出现这个错误是因为在64位的机器上无法执行32位的文件,所以需要安装个兼容库??
    然而在安装的过程中也出现了问题(后来切换到root上安装又可以了,什么鬼?)

    3、 Some Android licenses not accepted 错误,解决方案也给出了
    执行 flutter doctor --android-licenses,然后全部接受协议即可

    4、 Flutter plugin not installed,Dart plugin not installed 错误,打开Android studio装上就完了

    5、提示没安装Android studio,给Flutter指定Android Studio的安装路径即可,例如执行flutter config --android-studio-dir=/<user name>/Android Studio

    注意,每次安装完确实的依赖后都执行 Flutter doctor 查看是否安装成功

    附两个学习网站:
    https://flutter.dev/docs/get-started/install
    https://flutterchina.club


    更新 2019.04.18

    配置IOS开发环境

    1、安装Xcode

    2、安装brew(如果mac上没有安装的话)

    2、执行flutter doctor,按提示执行响应的命令,如

    
    **✗**** libimobiledevice and ideviceinstaller are not installed. To install with**
    
    **      Brew, run:**
    
    **        brew update**
    
    **        brew install --HEAD usbmuxd**
    
    **        brew link usbmuxd**
    
    **        brew install --HEAD libimobiledevice**
    
    **        brew install ideviceinstaller**
    
    **✗**** ios-deploy not installed. To install with Brew:**
    
    **        brew install ios-deploy**
    
    **✗**** Brew can be used to install tools for iOS device development.**
    
    **      Download brew at [https://brew.sh/.](https://brew.sh/)**
    
    

    期间,可能会出现

    
    chenwenhuideMacBook-Pro:~ chenwenhui$ brew install --HEAD libimobiledevice
    
    Updating Homebrew...
    
    ==> Cloning https://git.libimobiledevice.org/libimobiledevice.git
    
    Cloning into '/Users/chenwenhui/Library/Caches/Homebrew/libimobiledevice--git'...
    
    fatal: unable to access 'https://git.libimobiledevice.org/libimobiledevice.git/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
    
    Error: An exception occurred within a child process:
    
      DownloadError: Failed to download resource "libimobiledevice"
    
    Failure while executing; `git clone --branch master https://git.libimobiledevice.org/libimobiledevice.git /Users/chenwenhui/Library/Caches/Homebrew/libimobiledevice--git` exited with 128\. Here's the output:
    
    Cloning into '/Users/chenwenhui/Library/Caches/Homebrew/libimobiledevice--git'...
    
    fatal: unable to access 'https://git.libimobiledevice.org/libimobiledevice.git/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
    
    

    解决办法:翻墙,更新brew 软件源,多试几次

    解决之后,在执行flutter doctor,按提示执行响应命令

    
    **✗**** ios-deploy not installed. To install with Brew:**
    
    **        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**
    
    

    安装完后,在执行flutter doctor

    相关文章

      网友评论

          本文标题:Flutter初体验之安装Flutter(补)

          本文链接:https://www.haomeiwen.com/subject/qylqmqtx.html