flutter 配置 遇到的问题解决笔记

问题: flutter doctor 一直等待(转圈)

  • 1.打开全局翻墙
  • 2.将当前终端设置翻墙
export http_proxy=http://xxx:1087;export https_proxy=http://127.x.x.x:1087;
复制代码

问题: Android SDK not found at this location

ANDROID_HOME = /usr/local/opt/android-sdk 
but Android SDK not found at this location
复制代码

出现这种情况一般有2种原因

1. 没有安装Android SDK

  • 打开Andriod Studio – 左上角的 Preferences – System Setting – Android SDK
  • 配置 SDK Platforms 和 SDK Tools

wecom-temp-02fba67d4516eae7c43ec13ac4fa21ea.png
wecom-temp-fb6ee30bdd2991e292df2f5711b2add5.png

如果没有出现可选出现,需要先打开翻墙

2. 安装的SDK路径不对

wecom-temp-7339ebdc966385896b86884b85a7375d.png

  • 2.1 打开 bash或者zsh的配置文件,我这里是zsh,加上ANDROID_HOME。
# fluter 相关配置
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=/Users/xiuji/development/flutter/bin:$PATH
##  加上下面这句
export ANDROID_HOME=/Users/xiuji/Library/Android/sdk 
复制代码
  • 2.2 复制上图的地址,打开终端
flutter config --android-sdk "现在的Android SDK 路径"
eg:
flutter config --android-sdk /Users/xiuji/Library/Android/sdk
复制代码

先配置2.1,配置好后 重启终端, 运行 flutte rdoctor。 如果不行再进行2.2

问题: Android Studio not found at X/X

  • 在X/X这个路径下说找不到AS
  • 那就配置路径: 到应用程序中找到Android Studio,获取到这个应用的路径 (我的是Preview 版的),然后配置路径
flutter config --android-studio-dir=/Applications/Android\ Studio\ Preview.app
复制代码

问题: Some Android licenses not accepted

licenses没有接受

[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor
      --android-licenses
复制代码
  • 那就接受证书
flutter doctor --android-licenses
复制代码

运行后就会下载licenses,下载好后就会提示,让你接受,反正就是一直按y

Accept? (y/N): y
复制代码

所有licenses都接受后就会显示

All SDK package licenses accepted
复制代码

这步可能需要翻墙

M1版的AS

android-studio-apple-m1(preview)

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享