• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Flutter & Dart 安装在window系统

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

一、系统环境

flutter最低要求

1,windows7 SP1 64位版本以上,我的系统就是windows 7 sp1 64bit

2,git for windows ,没有安装的需要到这里下载 并安装

3,powershell 5.0及以上,这个据说只有windows10和2016版windows server满足要求

window7 sp1以及自带Powershell,但是版本较低,我的系统中版本居然是2.0

启动:系统左下角-开始-点击搜索框-输入powershell-回车键
在powershell中输入 $PSVersionTable 然后回车,查看其中的PSVersion一行


Windows PowerShell
版权所有 (C) 2009 Microsoft Corporation。保留所有权利。

PS C:\Users\gzg> $PSVersionTable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.8793
BuildVersion                   6.1.7601.17514
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1


PS C:\Users\gzg>
如何查看PowerShell版本

由于PS没有单独的发行包,只能下载WMF5.1的发行包

下载后展开,包含如下两个文件,右键点击Install-WMF5.1.ps1,选择用powershell运行安装,过程不赘述。

4,安装配置好android SDK,并建立一个模拟器

5,Android Studio,如果没有请安装http://www.androiddevtools.cn/。

二、下载安装flutter sdk

1,进入预存放flutter目录的父目录中,从github克隆flutter beta版

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

2,设置环境变量

1)将  *\flutter\bin目录加入到环境变量path中

2)添加ANDROID_HOME环境变量,指向android SDK所在目录

3, 设置国内镜像代理,然后执行flutter doctor

打开dos窗口,设置国内镜像

 set PUB_HOSTED_URL=https://pub.flutter-io.cn
 set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

备注:或者也可以直接添加系统变量,以备以后升级安装方便。

4,进行下一步之前,首先关闭杀毒杀木马程序,例如360之类,否则“flutter\bin\cache\artifacts\engine\android-arm64-release\windows-x64\gen_snapshot.exe” 会被认成木马,造成运行失败!

我这里的报错信息如下:

K:\Android\flutter>flutter doctor
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!

Oops; flutter has exited unexpectedly.
Sending crash report to Google.

或者,给目录“flutter\bin”添加到信任白名单。如果还有问题,看一看flutter目录下的“flutter_##.log”文件查找原因,然后在解决即可。

5,运行flutter设置命令

flutter doctor

flutter会检测flutter SDK安装情况,然后下载dart SDK和其他依赖项目,由于网络问题运行时间较长,期间不免发生失败情况,需要多运行几次。

PS C:\Users\gzg> flutter doctor
Downloading android-arm-release/windows-x64 tools...
Download failed -- attempting retry 1 in 1 second...
Download failed -- attempting retry 2 in 2 seconds...
Download failed -- attempting retry 3 in 4 seconds...
Download failed -- attempting retry 4 in 8 seconds...
Download failed -- attempting retry 5 in 16 seconds...
Download failed -- attempting retry 6 in 32 seconds...
Download failed -- attempting retry 7 in 64 seconds...
Download failed -- attempting retry 8 in 64 seconds...
365.2s
Downloading android-arm64-profile/windows-x64 tools...           8.2s
Downloading android-arm64-release/windows-x64 tools...           7.6s
Downloading android-x86 tools...
Download failed -- attempting retry 1 in 1 second...
Download failed -- attempting retry 2 in 2 seconds...
142.8s
Downloading android-x64 tools...                                53.4s
Downloading android-arm tools...                                24.4s
Downloading android-arm-profile tools...

Oops; flutter has exited unexpectedly.
Sending crash report to Google.
Failed to send crash report due to a network error: SocketException: OS Error: 信号灯超时时间已到
, errno = 121, address = clients2.google.com, port = 60527
Crash report written to C:\Users\gzg\flutter_03.log;
please let us know at https://github.com/flutter/flutter/issues.
PS C:\Users\gzg> flutter doctor
Downloading android-arm-profile tools...
Download failed -- attempting retry 1 in 1 second...
Download failed -- attempting retry 2 in 2 seconds...
Download failed -- attempting retry 3 in 4 seconds...
Download failed -- attempting retry 4 in 8 seconds...
Download failed -- attempting retry 5 in 16 seconds...
Download failed -- attempting retry 6 in 32 seconds...
254.5s
Downloading android-arm-release tools...
Download failed -- attempting retry 1 in 1 second...
61.0s
Downloading android-arm64 tools...                              27.6s
Downloading android-arm64-profile tools...
Download failed -- attempting retry 1 in 1 second...
71.0s
Downloading android-arm64-release tools...
Download failed -- attempting retry 1 in 1 second...
Download failed -- attempting retry 2 in 2 seconds...
Download failed -- attempting retry 3 in 4 seconds...
Download failed -- attempting retry 4 in 8 seconds...
Download failed -- attempting retry 5 in 16 seconds...

6,最后,flutter doctor命令会给出环境检测结果,如果有些项目有问题,则按照其中说明修正,例如,我这里有两项有问题:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel unknown, v0.0.0-unknown, on Microsoft Windows [Version 6.1.7601], locale zh-CN)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[√] Android Studio (version 3.2)
[√] IntelliJ IDEA Community Edition (version 2018.2)
[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.

 第二项问题依照蓝色提示操作即可解决。最后一项虚拟机,建立一个虚拟机并启动,再次运行检测,没问题了!

C:\Users\gzg>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel unknown, v0.0.0-unknown, on Microsoft Windows [Version 6.1.7601], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[√] Android Studio (version 3.2)
[√] IntelliJ IDEA Community Edition (version 2018.2)
[√] Connected device (1 available)

• No issues found!

三、开始flutter之旅

在android studio中建立flutter项目

菜单“File--New--New Flutter Project...”,第一步选择“Flutter Application”,第二部输入项目名称,注意一定要选中下面的选项“create project offline”,否则在我的网络环境下就进行不下去了。

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
dart 练习发布时间:2022-07-13
下一篇:
flutter笔记1:VScode安装dartcode插件踩坑记录发布时间:2022-07-13
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap