Flutter VScode开发环境搭建手册及问题记录
1、下载JDK(JDK1.8)
2、安装Android Studio并安装模拟器、启动模拟器
3、下载Flutter SDK
方法一:Git 下载
可以直接执行以下命令:
git clone -b master https://github.com/flutter/flutter.git
下载结束之后在Windows环境变量Path中添加Flutter路径
方法二:官网下载
https://flutter.dev/docs/development/tools/sdk/releases?tab=macos#windows
下载后操作同上
4、安装配置VSCode
安装Flutter和dart插件
安装完vscode之后再vscode的应用里安装flutter和dart这两个插件,一般先安装flutter之后dart也会已经自动安装。如图:
安装完成之后重启Vscode
运行flutter doctor命令检查环境
在vscode界面按下F1 或Ctrl+Shift+P: 打开命令面板。下拉找到这个点一下执行(或者直接cmd运行flutter doctor 命令即可)
一般来说会出现以下两个问题中的一个或者多个
报错1:找不到flutter SDK
点击Locate SDK,系统对话框弹出来选择刚刚下载好的flutterSDK,选择到flutterSDK主文件目录即可再次执行flutter doctor
报错2:Android licenses问题
对于这个错误执行提示中的命令,并一路选择y下去就好了
5、创建项目并运行
在vscode中运行
并命名你的工程
之后按f5进行运行(前提为启动模拟器)即可
Question
Could not resolve io.flutter:flutter_embedding_debug
报错内容:
Launching lib\main.dart on AOSP on IA Emulator in debug mode…
Running Gradle task ‘assembleDebug’…FAILURE: Build failed with an exception.
- What went wrong:
Could not determine the dependencies of task ‘:app:compileDebugJavaWithJavac’.Could not resolve all task dependencies for configuration ‘:app:debugCompileClasspath’.
Could not resolve io.flutter:flutter_embedding_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
Required by:
project :app
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/flutter_embedding_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/flutter_embedding_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> storage.googleapis.com
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/flutter_embedding_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/flutter_embedding_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> storage.googleapis.com
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/flutter_embedding_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/flutter_embedding_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> storage.googleapis.com
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://dl.google.com/dl/android/maven2/io/flutter/flutter_embedding_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/flutter_embedding_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://dl.google.com/dl/android/maven2/io/flutter/flutter_embedding_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/flutter_embedding_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> dl.google.com
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://jcenter.bintray.com/io/flutter/flutter_embedding_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/flutter_embedding_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://jcenter.bintray.com/io/flutter/flutter_embedding_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/flutter_embedding_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> jcenter.bintray.com
Could not resolve io.flutter:x86_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
Required by:
project :app
> Could not resolve io.flutter:x86_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> storage.googleapis.com
> Could not resolve io.flutter:x86_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> storage.googleapis.com
> Could not resolve io.flutter:x86_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> storage.googleapis.com
> Could not resolve io.flutter:x86_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://dl.google.com/dl/android/maven2/io/flutter/x86_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://dl.google.com/dl/android/maven2/io/flutter/x86_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> dl.google.com
> Could not resolve io.flutter:x86_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://jcenter.bintray.com/io/flutter/x86_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://jcenter.bintray.com/io/flutter/x86_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> jcenter.bintray.com
Could not resolve io.flutter:x86_64_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
Required by:
project :app
> Could not resolve io.flutter:x86_64_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_64_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_64_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> storage.googleapis.com
> Could not resolve io.flutter:x86_64_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_64_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_64_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> storage.googleapis.com
> Could not resolve io.flutter:x86_64_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_64_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_64_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> storage.googleapis.com
> Could not resolve io.flutter:x86_64_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://dl.google.com/dl/android/maven2/io/flutter/x86_64_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_64_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://dl.google.com/dl/android/maven2/io/flutter/x86_64_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_64_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> dl.google.com
> Could not resolve io.flutter:x86_64_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.
> Could not get resource ‘https://jcenter.bintray.com/io/flutter/x86_64_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_64_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> Could not GET ‘https://jcenter.bintray.com/io/flutter/x86_64_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_64_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.pom'.
> jcenter.bintray.com
Try:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output. Run with –scan to get full insights.Get more help at https://help.gradle.org
BUILD FAILED in 9s
Exception: Gradle task assembleDebug failed with exit code 1
报错原因:
It may be the case of using flutter behind a country firewall
解决办法:
进入flutter工程的android目录,找到build.gradle文件:
在文件的两个repositories下添加中国的maven url