flutter环境配置

一、flutter 中文网

https://flutterchina.club/setup-macos/

mac配置环境

提前安装GIt工具  使用git clone -b beta https://github.com/flutter/flutter.git 命令克隆flutter

1.打开终端输入 :sudo vi ~/.bash_profile   进入配置文件

2.添加镜像,a编辑,编辑完之后,按ESC键,输入:wq保存退出

//第一个路径中/Users/zixiao/Downloads/flutter填入自己flutter路径

export PATH=/Users/zixiao/Downloads/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

3.执行source ~/.bash_profile刷新更改的文件

4.执行flutter doctor 它会下载它自己的依赖项并自行编译。

5.之后配置android studio或xcode 祥见flutter中文网。

6.Android studio中安装 flutter 和dart 插件,并配置路径

遇到的问题:

1.-bash: flutter: command not found 或者 zsh: command not found: flutter

答:配置的 bash_profile 文件有问题,请仔细检查路径

2. The Flutter directory is not a clone of the GitHub project.
       The flutter tool requires Git in order to operate properly;
       to install Flutter, see the instructions at:
       https://flutter.dev/get-started

答:flutter需要克隆,安装git工具  使用命令:

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

获取flutter并配置到bash_profile文件中

3.在flutterSDK中, flutter\packages\flutter_tools\gradle\flutter.gradle  路径下配置阿里云镜像,增加下载速度

buildscript {
    repositories {
        // google()
        // jcenter()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'http://download.flutter.io'}

        // maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/public' }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
    }
}
...
class FlutterPlugin implements Plugin {
    // 此处也要修改其值
    private static final String MAVEN_REPO      = "https://storage.flutter-io.cn/download.flutter.io";
...
 

4.A problem occurred evaluating settings ... \flutter_plugin\.android\include_flutter.groovy)

问题

答:Caused by: java.io.FileNotFoundException: 需要重新编译flutter项目,flutter packages get

或者  目录名称不全改为'工程名/flutter_module/.android/include_flutter.groovy'

5.Because flutter_plugin requires SDK version >=2.16.0-20.0.dev <3.0.0, version solving failed.

答:查看flutter项目中 pubspec.yaml文件修改版本号 ,或者下载响应版本号的flutterSDK


 

你可能感兴趣的:(开发,flutter,android,xcode)