首页 > 系统相关 >windows下flutter的环境安装

windows下flutter的环境安装

时间:2023-09-07 21:11:55浏览次数:38  
标签:windows com final maven version https 安装 flutter

Flutter是谷歌出品的移动应用SDK,性能卓越、体验精美、跨平台、HotReload等等这些特点。

Dart是谷歌推出的编程语言。支持即时编译JIT(Just In Time)、HotReload(热加载)和事前编译AOT(Ahead of Time)。

所以搜索语法要用dart。

一、下载

二、环境变量

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

注意:这两个环境变量一定要加,否则可能导致后面 flutter doctor 命令连接不上服务

三、安装

安装git

安装android studio

会让你下载SDK,记一下路径,然后配置到环境变量中。

ANDROID_HOME = Android sdk路径

如果忘记了或者没记或者跳过了安装安卓SDK的步骤:

Alt text

Alt text

安装Flutter SDK

把之前下载的SDK直接解压。
比如我的是:C:\sdk\flutter

然后把bin目录配置到环境变量中:

C:\sdk\flutter\bin

Alt text

打开cmd检测下:

flutter --version 查看是否安装成功
flutter -h  能够展示指令,表示安装配置成功

四、flutter doctor 环境检测

在前面都安装完后,才是正式安装的开始。

打开cmd,运行 flutter doctor
Alt text

这是运行成功的例子,那么哪个不对改哪里。

4.1 安卓SDK下载不了

AppData\\Roaming\\Google 下缓存删掉

4.2 HTTP Host availability check is taking a long time...

img

  1. 找到flutter sdk的文件目录,依次找到flutter/packages/flutter_tools/lib/src/http_host_validator.dart文件
  2. https://maven.google.com/ 修改为https://dl.google.com/dl/android/maven2/
  3. 关闭所有打开了flutterSDK的程序,找到flutter\bin目录下的flutter_tools.snapshot文件,删除。
  4. 重新打开cmd,再试。(注意要重新打开)

4.3 Windows Version (Unable to confirm if installed Windows version is 10 or greater)

  1. 打开:\packages\flutter_tools\lib\src\windows\windows_version_validator.dart
  2. 直接替换:
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:process/process.dart';

import '../base/io.dart';
import '../doctor_validator.dart';

// FIX #1 - Remove everything from line 10 to 20 in original source code.

/// Validator for supported Windows host machine operating system version.
class WindowsVersionValidator extends DoctorValidator {
  const WindowsVersionValidator({required ProcessManager processManager})
      : _processManager = processManager,
        super('Windows Version');

  final ProcessManager _processManager;

  @override
  Future<ValidationResult> validate() async {

// FIX #2 - Replace 'systeminfo' by 'ver' command
    final ProcessResult result =
        await _processManager.run(<String>['ver'], runInShell: true);

    if (result.exitCode != 0) {
      return const ValidationResult(
        ValidationType.missing,
        <ValidationMessage>[],
        statusInfo: 'Exit status from running `systeminfo` was unsuccessful',
      );
    }

    final String resultStdout = result.stdout as String;

// FIX #3 - Remove brackets from output
    final String resultAdjusted = resultStdout.replaceAll('[','').replaceAll(']','');

// FIX #4 - Split the output at spaces, and get Windows version at position 3.
//          Split again at dots and get the major version at position 0.
//          Cast the output to int.
    final int winver = int.parse(resultAdjusted.split(' ').elementAt(3).split('.').elementAt(0));

    // Use the string split method to extract the major version
    // and check against the [kUnsupportedVersions] list
    final ValidationType windowsVersionStatus;
    final String statusInfo;

// FIX #5 - Check if Windows major version is greater than 10.
//          Succeeds if true.
    if (winver >= 10) {
      windowsVersionStatus = ValidationType.installed;
      statusInfo = 'Installed version of Windows is version 10 or higher';
    } else {
      windowsVersionStatus = ValidationType.missing;
      statusInfo =
          'Unable to confirm if installed Windows version is 10 or greater';
    }

    return ValidationResult(
      windowsVersionStatus,
      const <ValidationMessage>[],
      statusInfo: statusInfo,
    );
  }
}

  1. 删除文件:\bin\cache\flutter_tools.stamp
  2. 重新打开cmd,再试。(注意要重新打开)

4.4 如果不在PC上运行,Visual Studio 不用管。

4.5 android-licenses

这个是需要同意一下协议。

flutter doctor --android-licenses
然后全部同意就行了。

五、使用

5.1 找不到dart sdk

C:\\sdk\\flutter\\bin\\cache\\dart-sdk

5.2 卡在Running Gradle task 'assembleDebug'

属于网络问题,国内对一些镜像是有墙的,换一下就行。你自己翻也行。

  1. 打开flutter\packages\flutter_tools\gradle\flutter.gradle
  2. 改:
private static final String DEFAULT_MAVEN_HOST = "https://storage.googleapis.com";

改成:

"https://storage.flutter-io.cn";
buildscript {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { allowInsecureProtocol = true
            url 'http://maven.aliyun.com/nexus/content/groups/public' }
        //google()
        //mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { allowInsecureProtocol = true
            url 'http://maven.aliyun.com/nexus/content/groups/public' }
        //google()
        //mavenCentral()
    }
}
  1. 重新编译运行即可。

项目文件中android/build.gradle也有相关配置,改一下也可以,即只对项目生效。

5.3 Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven...

这是因为上一个问题中:allowInsecureProtocol = true没有加,或者路径没有加https。

六、总结

Flutter使用的是谷歌生态,所以有很多网络不通的情况,如果编译卡住了,可以首先怀疑是网络墙了。

这是我个人安装过程中的一些问题,如果还有其他问题,欢迎评论补充。如果有不对的,或者试了没有效果的,也欢迎指正。

标签:windows,com,final,maven,version,https,安装,flutter
From: https://www.cnblogs.com/HappyTeemo/p/17679710.html

相关文章

  • codeblock安装及汉化教程
      1.双击图标   2.弹出如下对话框:  3、单击按钮Next,弹出如下对话框:  4、单击按钮IAgree,弹出如下对话框:  5、单击按钮Next,弹出如下对话框:  6、单击Browse按钮,可以重新设置安装路径  7、路径重新设置后,单击确定按钮弹出如下对话框(注意,此......
  • ubuntu安装redis
    sudoaptinstallredis-server检查运行状态sudosystemctlstatusredis-server出现以下就是在运行redis-server.service-Advancedkey-valuestoreLoaded:loaded(/lib/systemd/system/redis-server.service;enabled;vendor>Active:activating(start)......
  • Windows下python,psycopg2连接HGDB
    瀚高数据库目录环境文档用途详细信息环境系统平台:N/A版本:4.5文档用途 本文介绍在HGDB使用sm3认证时,python使用psycopg2连接HGDB的方法。详细信息 Python连接HGDB可以使用psycopg2、Django,Django是依赖psycopg2的,底层用的都是libpq,pip安装的psycopg2自带libpq。因此在一般情况下......
  • Python预安装包制作
    预编译安装包在Linux服务器上,经常会安装Python、Redis、Nginx等服务,不管离线、在线都需要编译、编译之前还需要安装一些依赖的环境,比如,openssl、gcc、g++等,但是make编译的时间过于长,严重影响心情,希望制作一个符合当前系统的预先编译好的包,可以拿来即用的。编译Python3.9.8在......
  • 云服务器——安装Maven
    1.首先新建一个maven文件夹用于下载maven安装包,可采用直接官网下载压缩包上传至服务器,也可以采用wget直接下载,这里采用wget下载wgethttps://archive.apache.org/dist/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.tar.gz2.下载完之后解压缩tar-zxvfapache-maven-3.......
  • 使用VMware创建虚拟机关于VMware Tools无法安装的问题
    VM版本:操作系统版本:WindowsServer2008R2x641、虚拟机菜单下的安装VMwareTools为灰色解决方案:在虚拟机设置中,找到CD/DVD,选择使用ISO映像文件,找到VMware安装路径下的windows.iso(linux系统选择linux.iso)设置好后,在虚拟机中的光盘中就可以已找到安装程序了,双击安装即可:......
  • Windows Server 2016 更改远程桌面端口
     WindowsServer2016更改远程桌面端口操作步骤:步骤一:在服务器运行窗口中输入“regedit”打开注册表编辑器。 步骤二:在注册表HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TerminalServer\Wds\rdpwd\Tds\tcp目录下,修改PortNumber数值,将其修改为你想要的修改的......
  • VMware vCenter Server 7.0.3 安装
    VMwarevCenterServer7.0.3安装文章目录VMwarevCenterServer7.0.3安装1.安装vcenter1.1第一阶段1.2第二阶段2.exsi查看vcenter3.部署DNSserver3.1安装unbound3.2配置unbound3.3vcenter配置域名访问部署完EXSI7.0.3,你要在EXSI创建一台windows10虚拟机,在......
  • 【ROS2机器人入门到实战】Micro-ROS介绍与服务安装
    1.Micro-ROS介绍与服务安装写在前面当前平台文章汇总地址:ROS2机器人从入门到实战获取完整教程及配套资料代码,请关注公众号<鱼香ROS>获取教程配套机器人开发平台:两驱版|四驱版为方便交流,搭建了机器人技术问答社区:地址fishros.org.cn你好,我是爱吃鱼香ROS的小鱼。本节我们主要介绍下......
  • docker下的php7.3容器安装gd库
    我的docker版本,24.0.5 我的php版本,php7.3.33题外话,之前我们单独安装php-fpm服务的时候,需要装扩展,是直接在服务器上操作的,那么现在php在docker里面了,我们应该怎么来执行安装操作呢1、进入php容器dockerexec-it1e36f97ab14c/bin/bash//1e36f97ab14c为我的php容器的ID......