android flutter mac,Mac AndroidStudio flutter环境

本文介绍了如何在本地设置Flutter开发环境,包括添加环境变量、安装Android Studio插件以及解决国内网络限制。在配置过程中,可能会遇到Android licenses未接受、iOS工具链不完整、CocoaPods未安装等问题,解决方案包括运行`flutter doctor --android-licenses`同意许可,使用国内镜像加速下载,并手动安装缺失的工具。此外,还提到了如何处理`flutter packages get`长时间加载的问题,即设置环境变量并使用国内镜像源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先克隆基础flutter项目到本地

添加在./.base_profile中添加flutter环境变量:

export PATH_TO_FLUTTER_GIT_DIRECTORY=/Users/用户名/flutter

export PATH=

math?formula=%7BPATH%7D%3A{PATH_TO_FLUTTER_GIT_DIRECTORY}/bin

在AndroidStudio中安装flutter的plugin

由于国内网络限制可修改镜像地址解决,如下:

export PUB_HOSTED_URL=https://pub.flutter-io.cn

export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

git clone -b dev https://github.com/flutter/flutter.git

export PATH="

math?formula=PWD%2Fflutter%2Fbin%3APATH"

cd ./flutter

flutter doctor

doctor检测完毕后可能遇到如下:

[✓] Flutter (Channel beta, v1.1.8, on Mac OS X 10.14.2 18C54, 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

[!] iOS toolchain - develop for iOS devices (Xcode 10.1)

✗ 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:

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

[✓] Android Studio (version 3.2)

[!] IntelliJ IDEA Ultimate Edition (version 2018.1.2)

✗ Flutter plugin not installed; this adds Flutter specific functionality.

✗ Dart plugin not installed; this adds Dart specific functionality.

[!] Connected device

! No devices available

! Doctor found issues in 4 categories.

第一个感叹号,是需要同意证书问题。输入命令:

flutter doctor --android-licenses

然后一路y,同意就行了。

然后在AndroidStudio新建项目时候会发现fluter项目了。

如果在安装中或者运行中出现:

Waiting for another flutter command to release the startup lock...

解决:则删除flutter/bin/cache/lockfile文件。然后重启AndroidStudio或者terminal

如果遇到下载问题比如:flutter packages get一直loading。有可能被墙了。

解决:

添加环境变量:在./.bash_profile添加镜像

export PUB_HOSTED_URL=https://pub.flutter-io.cn

export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

然后source ./.bash_profile 立即生效。重新打开terminal,执行flutter doctor命令。这样这个镜像就起作用了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值