安装Flutter

1、安装jdk

  • 安装
  • 环境变量

2、安装Android Studio

  • sdk安装目录

3、安装Flutter

  • 下载flutter SDK:下载地址
  • 解压并配置环境变量
  • 配置ANDROID_HOME环境变量
  • 配置国内镜像
     export PUB_HOSTED_URL=https://pub.flutter-io.cn
     export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
    
  • 执行flutter doctor检测
    [√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18363.997], locale zh-CN)
    [√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    [√] Android Studio (version 4.0)
    [!] Connected device
    ! No devices available
    
  • 第一次安装需要统一协议,根据提示执行flutter doctor --android-licenses,根据提示输入Y

4、安装Flutter插件

5、修改gradle国内镜像

在c盘用户.gradle文件夹种创建init.gradle添加以下内容

allprojects{
    repositories {
        def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
        def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
        all { ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
                    remove repo
                }
                if (url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
                    remove repo
                }
            }
        }
        maven {
            url ALIYUN_REPOSITORY_URL
            url ALIYUN_JCENTER_URL
        }
    }
}
posted @ 2023-08-18 21:44  路暝月  阅读(37)  评论(0编辑  收藏  举报  来源