Flutter系列笔记1--简介与环境搭建

Flutter简介

Flutter 是谷歌公司开发的一款开源、免费的移动 UI 框架,可以让我们快速的在 Android 和 iOS 上构建高质量 App。它最大的特点就是跨平台、以及高性能。 Flutter 基于谷歌的 dart 语言。

搭建开发环境

这里我们是在windows上开发的,别问为什么。(穷)

  • 安装JDK
  • 安装AndroidStudio
https://developer.android.google.cn/studio
  • 下载安装Flutter
//官网
https://flutter.dev/docs/development/tools/sdk/releases#windows
//中文社区
https://flutter.cn/docs/get-started/install/windows

从上面两个网址中任选一个下载Flutter SDK,(由于各种原因,这个过程可能有点慢,可以先出去买个零食再回来)这里我下载的是flutter_windows_v1.9.1+hotfix.6-stable.zip。下载到你喜欢的目录下,我这里是D:\gxh\a_tool\flutter。然后解压,配置环境变量。变量名Path,变量值D:\gxh\a_tool\flutter\flutter_windows_v1.9.1+hotfix.6-stable\flutter\bin。

  • 在AndroidStudio里安装Flutter插件

在"Welcome to AndroidStudio"页面的Configure->Plugins里面搜Flutter,安装后重启AS即可。这个时候你就可以在"Welcome to AndroidStudio"页面看到 Start a new Flutter project了。

  • 创建项目

点击"Start a new Flutter project"就可以创建一个Flutter项目了(点击后可能会卡死一会,请耐心等待),中途有个Flutter SDK path需要填一下,不出意外的话AS可能自动填好了。我这里是D:\gxh\a_tool\flutter\flutter_windows_v1.9.1+hotfix.6-stable\flutter。

  • 真机调试
其实有安卓开发经验的人应该知道怎么调试,没有太多额外的东西。
手机与电脑用数据线相连,手机开启调试模式,手机对应的sdk版本必须安装。
VS code中开发
  • 在VS code中安装Flutter、Flutter Widget Snippets、Dart三个插件。
  • 命令创建项目后用VS code打开即可
flutter create 项目名
  • 运行项目
flutter run
问题解决
* Error running Gradle:
ProcessException: Process "D:\gxh\sdc\demo\flutter_app\android\gradlew.bat" exited abnormally:

> Configure project :app
Checking the license for package Android SDK Build-Tools 28.0.3 in C:\Users\SUONI\AppData\Local\Android\sdk\licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 28 in C:\Users\SUONI\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:\gxh\sdc\demo\flutter_app\android\build.gradle' line: 26

* 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.
        build-tools;28.0.3 Android SDK Build-Tools 28.0.3
        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

     Using Android SDK: C:\Users\SUONI\AppData\Local\Android\sdk

* 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 4s
  Command: D:\gxh\sdc\demo\flutter_app\android\gradlew.bat app:properties


Please review your Gradle project setup in the android/ folder.

下载28.0.3

还有遇到了跟此文类似的问题:可以参考此文章 因为我没有记录下问题,已经没法重现了。第二个问题中Android license status unknown,我按照解决方案但是一直提示我jdk路径无效,试了好几次只好卸载重装jdk。

最后的最后,不要问我为什么又开始写博客了,因为心情不好。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值