本文主要是介绍Flutter环境搭建采坑大全,报错The Flutter directory is not a clone of the GitHub project和Error running Gradle及解决,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.安装Flutter,推荐 Flutter中文网
这个网站的介绍还是比较全,国内需要配置临时镜像,配在用户变量就行,我是直接配在系统变量里,如下图
在github上下载完Flutter后并解压,记得在Path里配flutter的环境
重启让环境变量生效,在基本操作都做完后打开cmd无比激动的敲下了flutter doct
Error: The Flutter directory is not a clone of the GitHub project.The flutter tool requires Git in order to operate properly;to set up Flutter, run the following command:git clone -b beta https://github.com/flutter/flutter.git
- 解决方法
把刚刚下载的
Flutter
安装包删掉,重新在想要安装的目录下运行git clone -b beta https://github.com/flutter/flutter.git
等待下载完毕,再次验证,看到如下图说明安装成功(感谢https://segmentfault.com/a/1190000017403839)
2.使用Android studio3.0以上创建你的第一个flutter项目New Flutter Project
打开File->New ->发现没有New Flutter Project
解决:
然后配上Flutter安装目录
然后就可以愉快的创建第一个flutter项目,一路默认就行(感谢https://www.cnblogs.com/niceyoo/p/9240359.html)
3.运行项目
3.1Error running Gradle 错误
首先修改项目build.gradle,注释掉jcenter(),google()。使用阿里的镜像。原因是jcenter google库无法访问到导致的问题。虽然我有万能的爬墙工具,开启全局代理依然被我们伟大的发改委墙掉了!
然后找到flutter安装目录的flutter.gradle文件
修改跟上面一样,如下图
3.2 出现如下错误的解决办法
ProcessException: Process “D:\project\Flutter\flutter_app\android\gradlew.bat” exited abnormally:
> Configure project :app
Checking the license for package Android SDK Platform 28 in C:\Users\Administrator.WINMICR-H4QQDHF\AppData\Local\Android\Sdk\licenses
Warning: License for package Android SDK Platform 28 not accepted.
FAILURE: Build failed with an exception.
* Where:
Build file ‘D:\project\Flutter\flutter_app\android\build.gradle’ line: 30
* What went wrong:
A problem occurred evaluating root project ‘android’.
> A problem occurred configuring project ‘:app’.
> Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-28 Android SDK Platform 28
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
大概的意思就是需要您接受SDK许可协议,根据上面SDK的地址,找到bin目录,如下
在此目录 按住shitf键同时右击,在此处打开命令窗口,cmd里输入sdkmanager --licenses
一路按y,回车到最后就行了,表示同意协议。
最后来一张运行图
谢谢大家,如有不对请指出,感谢!
这篇关于Flutter环境搭建采坑大全,报错The Flutter directory is not a clone of the GitHub project和Error running Gradle及解决的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!