Fydeos 配置Flutter开发环境

Author: Elimos
Date Created: April 9, 2022 1:26 PM
Status: Done 🙌
Tags: ChromeOS, Coding, Devices, Flutter, Learning, Tutorial

在 Linux 操作系统上安装和配置 Flutter 开发环境

前期准备

FydeOS开启Linux环境

FydeOS使用的是基于Debian的Linux环境

  1. 打开”系统设置-在左侧菜单栏-高级-开发者”中找到Linux开发环境 按照提示开启即可 成功开启linux开发环境后界面

成功开启linux开发环境后界面

  1. 点开右侧小三角

Linux环境配置

Linux环境配置

  1. 进入开发Andorid应用,并开启adb调试

启用adb调试

启用adb调试

Linux环境软件源更换

Fydeos中使用的debian版本为bullseye,于是笔者使用了清华大学软件源来替换官方源

debian | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

更换镜像源

1
2
3
4
5
6
7
# 备份镜像源文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

# 编辑镜像源文件
sudo vim /etc/apt/sources.list

# 修改文件内容为如下内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#deb https://deb.debian.org/debian bullseye main
#deb http://deb.debian.org/debian/ bullseye main contrib non-free
#deb https://security.debian.org/ bullseye-security main contrib non-free

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
1
2
# 保存退出后更新软件列表
sudo apt-get install update

FydeOS开启Android环境

在软件列表中,找到安卓设置,打开即成功开启Android环境

配置ADB环境

在debian中安装adb工具

1
sudo apt-get install adb

验证adb环境

1
adb devices

执行后,会提示

1
2
3
4
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
emulator-5554 unauthorized

并且会弹出adb链接确认框,勾选一律允许后确认,再执行 adb devices

1
2
List of devices attached
emulator-5554 device

至此linux环境与fydeos的android环境成功打通

Linux安装VS Code

直接官网下载 选择deb版 下载完成后点击安装即可

配置FydeOS&Linux共享目录

笔者把下载目录与Linux进行共享,读者可根据自己的需求进行更改

在文件管理器中,右击左侧的”下载内容“文件夹,点选与Linux共享即可

共享后的下载目录在

/mnt/chromeos/MyFiles/Downloads/

下载目录


软件准备

flutter下载

在flutter的官方下载页面https://flutter.cn/docs/get-started/install/linux

找到如下界面 ,点击进行下载

下载界面

下载界面

https://storage.flutter-io.cn/flutter_infra_release/releases/stable/linux/flutter_linux_2.10.4-stable.tar.xz

这里贴出笔者配置时使用的链接

下载到Fydeos后,进入linux终端

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 将下载来的flutter环境移动到/tmp目录
sudo mv /mnt/chromeos/MyFiles/Downloads/f[lutter_linux_2.10.4-stable.tar.xz](https://storage.flutter-io.cn/flutter_infra_release/releases/stable/linux/flutter_linux_2.10.4-stable.tar.xz) /tmp

# 解压flutter环境到/lib目录
sudo tar -zxf /tmp/flutter_linux_2.10.4-stable.tar.xz /lib

# 删掉已经解压之后没用了的压缩包
sudo rm /tmp/flutter_linux_2.10.4-stable.tar.xz

# 将flutter添加到环境变量
sudo vim /etc/profile
# 在文件末尾添加
export PATH=$PATH:/lib/flutter/bin

# 保存退出 使环境变量生效
source /etc/profile

# 测试flutter
flutter doctor

Android Studio安装

Download Android Studio and SDK tools | Android Developers

打开AS官网,按照提示下载,在下载内容目录直接点开进行安装即可

进入软件后,点不导入配置,不设置代理即可,默认安装完成即可进入软件

AS

进入软件后,如图选SDK Manager

SDK Manager

勾选Android SDK Command-line Tools(latest) 点右下角的finish,等待安装完成

安装环境

上一步安装完成后,打开linux终端

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 配置Andorid SDK 路径 directory处填写上图中显示的SDK位置,如笔者是/home/elimos/Android/Sdk
flutter config --android-sdk <directory>

# 同意协议 一路y即可
flutter doctor --android-licenses

# 验证环境
flutter doctor

### 配置成功后提示如下
elimos@penguin:~$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.4, on Debian GNU/Linux 11 (bullseye)
5.4.151-16908-gff376e5d5ee1, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.66.0)
[✓] Connected device (1 available)
###

由于并不需要开发web应用,对于chrome的报错笔者就不理会了,至此Flutter的FydeOS开发环境搭建完成

Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2022 Elimos
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信