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,回车到最后就行了,表示同意协议。

最后来一张运行图

谢谢大家,如有不对请指出,感谢!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值