Flutter 环境搭建问题记录

问题:运行 flutter doctor 命令卡住问题解决
解决:设置国内镜像

mac
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
windows
![捕获.PNG](https://upload-images.jianshu.io/upload_images/9196938-f7502583872c2e8e.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

问题:Flutter 编译卡住 Running Gradle task 'assembleDebug'
解决: 修改\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.5.0'
    }
}

android 工程目录修改build.gradle文件,替换国内镜像地址

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        maven{ url 'https://maven.aliyun.com/repository/google'}
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/jcenter'}
//        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.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/gradle-plugin'}
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/jcenter'}
//        google()
        jcenter()
    }
}

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

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

你可能感兴趣的:(Flutter 环境搭建问题记录)