环境安装参考官网 https://docs.flutter.cn/get-started/install/windows/mobile?tab=download
1.新建项目
使用vscode 按住ctrl+shift+p 选择flutter:new Project
2.修改安卓目录下的build.gradle
allprojects { repositories { maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/jcenter' } maven { url 'https://maven.aliyun.com/nexus/content/groups/public' } google() mavenCentral() } } rootProject.buildDir = "../build" subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(":app") } tasks.register("clean", Delete) { delete rootProject.buildDir }
3.flutter pub 国内镜像
export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=20240718最新的用清华的 FLUTTER_STORAGE_BASE_URL="https://mirrors.tuna.tsinghua.edu.cn/flutter" PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub"
4.下载gradle慢的话 参考 https://knsay.com/article/454
5.编译报错 参考 https://knsay.com/article/580 https://knsay.com/article/585
6.最后执行 main.dart 下的main方法
7.编译为安卓
flutte build apk
本文为看恩吧原创文章,转载无需和我联系,但请注明来自knsay.com