# 安装

入门: 在macOS上搭建Flutter开发环境 (opens new window)

# Install

  1. 下载 v1.9.1+hotfix.6 (opens new window)

  2. 解压到 /Users/zhangwenbo/Coding/Flutter/flutter

  3. 添加环境变量 ~/.zshrc

    # Flutter
    export PATH=/Users/zhangwenbo/Coding/Flutter/flutter/bin:$PATH
    
  4. 查看依赖 flutter doctor

# 编辑器

  • IntelliJ IDEA

    安装插件:Dart, Flutter

  • xcode

  • Android Studio

# Android设置

  1. 安装 Android Studio

  2. 问题:Android license status unknown.

    https://github.com/flutter/flutter/issues/16025#issuecomment-530882482

    问题:adb server didn't ack * failed to start daemon *

    # 查看连接的设备
    adb devices
    
    # 先关闭 IDE
    adb kill-server
    

adb start-server

# 打开 IDE





## 配国内代理

export PUB_HOSTED_URL=https://pub.flutter-io.cn //国内用户需要设置 

export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn //国内用户需要设置



## Flutter 版本管理

[升级 Flutter](https://flutterchina.club/upgrading/)

```bash 
flutter channel # 查看分支
flutter channel master # 切换分支到 master
flutter upgrade # 在项目根目录执行,更新 Flutter SDK 和你的依赖包
flutter packages get # 获取 pubspec.yaml文件中依赖
flutter packages upgrade # 升级 pubspec.yaml 文件中依赖

# Debug

  1. flutter : Failed to find assets path for "Frameworks/App.framework/flutter_assets"

Channel master -> channel stable 出现问题,按照 https://flutter.dev/docs/development/ios-project-migration 处理, Change the Runner target build settings Build Phases > Thin Binary script as follows,再次启动即可。

  1. Running pod install Error

    flutter clean // 清理缓存
    
    // 查看 gem 源
    gem source -l 
    
    // 配置 gem 镜像
    gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
    
    sudo gem install cocoapods // 更新 cocoapods
    
    • Finder前往~/Library/Caches 清空
    • Android Studio 重启
  2. gradle 问题 https://cloud.tencent.com/developer/article/1723914

问题出在 路径/flutter/packages/flutter_tools/gradle/flutter.gradle 里 tools 版本不对

  dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
    }

# 问题

  • CocoaPods's specs repository is too out-of-date to satisfy dependencies.
  1. Go to /ios folder inside your Project.
  2. Delete Podfile.lock
  3. Run pod install --repo-update
  4. Run flutter clean
  5. Once complete, rebuild your Flutter application: flutter run
  • Exception in thread "main" java.util.zip.ZipException: error in opening zip file

Go to flutter_app>android> and delete gradle folder, delete gradlew files and run the app again using flutter run

I just ran flutter upgrade and flutter clean and it solved this issue in my case.

https://stackoverflow.com/questions/62394034/flutter-can-not-build-android-apk

Last Updated: 5/14/2022, 11:38:45 AM