mac,flutter环境配置

1:下载flutter的SDK https://flutter.dev/docs/get-started/install/macos

2:打开终端

     输入:open -e .bash_profile

  1. export PATH=/Users/bai/flutter/bin:$PATH

  2. export PUB_HOSTED_URL=https://pub.flutter-io.cn

  3. export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

     输入:source ~/.bash_profile

     终端执行flutter doctor 检查环境

3:去Android studio里面打开设置--plugins--安装flutter和Dart,然后重启Android  studio

4:配置flutter dart sdk路径

遇到gradle assembleDebug解决方案:

运行时会卡在Running 'gradle assembleDebug, 因为Gradle的Maven仓库在国外, 可以使用阿里云的镜像地址。

* 修改项目中`android/build.gradle`文件

 

buildscript {
    repositories {
        //修改的地方
        //google()
        //jcenter()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

allprojects {
    repositories {
        //修改的地方
        //google()
        //jcenter()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

* 修改Flutter的配置文件, 该文件在`Flutter安装目录/packages/flutter_tools/gradle/flutter.gradle`

buildscript {
    repositories {
        //修改的地方
        //google()
        //jcenter()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

Flutter android GradleException显示红色报错解决办法

throw new GradleException(...)

替换

throw new Exception(...)

参考:https://blog.csdn.net/androidwubo/article/details/88530966

你可能感兴趣的:(mac,flutter环境配置)