当前位置:网站首页>搭建flutter环境入坑集合
搭建flutter环境入坑集合
2022-07-06 09:29:00 【社会你磊哥,命硬不弯腰】
搭建flutter环境用了4个下午,真可谓是人生到达了高潮。听人说mac比较好配环境,不过我用的是windows,唉,该遇到的坑基本上统统走了一遍。搭建环境那个我就不讲了,大家可以看一下技术胖的视频在b站上,就说一下遇到的坑,来正文吧。
问题一:遇到了get packages第三方包问题。没有这玩意代码在编译器环境中会直接报错,获取的方式有两种,第一种是翻墙,这种方式对梯子的要求还是有点高的,不建议使用。第二种是flutter专门照顾国内用户的,设置镜像源可解决问题。
FLUTTER_STORAGE_BASE_URL = https://storage.flutter-io.cn
PUB_HOSTED_URL = https://pub.flutter-io.cn

强烈建议在这里关闭电脑,重新开启在遇到flutter create project项目失败或者编译器get packages第三方包报错的时候。
问题二 Plugin with id 'kotlin-android' not found这个错误我解决了很久没有解决,在别人帮我解决好问题后得到了解答。这是因为没有正确的引入kotlin-android插件而产生的错误
第一步:在项目android\app目录下build.gradle文件中插入,看清楚是在app目录下的这个文件
apply plugin: 'kotlin-android'
这段代码
效果图如上所示
第二步 项目的androd目录下也有一个build.gradle文件,打开并分别添加下面两段代码在固定的位置
ext.kotlin_version = '1.3.50'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

注意第一段代码是在那个对象的外面,我在调试的过程中放错了位置,导致走了更多的坑。这个问题不出意外已经解决了。
问题三:还有人可能会报这个错误,这个问题我好像没遇到,我调试之前照着技术胖的博客改了一下,这个也是因为墙的原因吧。
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "/Users/rabbit/develop/android/flutter_app/android/gradlew" exited abnormally:
Project evaluation failed including an error in afterEvaluate {
}. Run with --stacktrace for details of the afterEvaluate {
} error.
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/rabbit/develop/android/flutter_app/android/app/build.gradle' line: 25
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not resolve all files for configuration 'classpath'.
> Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar
* 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 0s
Command: /Users/rabbit/develop/android/flutter_app/android/gradlew app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.
针对这个错误大家可以参考一下技术胖的博客https://jspang.com/detailed?id=41#toc222,注意需要改两个文件。
问题四:最后就是需要大家注意gradle版本和它插件之间应该是对应的关系,下面有一个表


我这里插件的版本是3.5.0,gradle版本是5.6.2.符合规定。第二个文件的目录是项目\android\gradle\wrapper,查看那个文件就行,不符合上面那个表就更改。
边栏推荐
- Continue and break jump out of multiple loops
- 第2章 HFDS的Shell操作
- 字节跳动2022校招研发提前批宣讲会,同学们最关心的10个问题
- 我走过最迷的路,是字节跳动程序员的脑回路
- Cmake Express
- Business system compatible database oracle/postgresql (opengauss) /mysql Trivia
- ~81 long table
- SQL快速入门
- 字节跳动新程序员成长秘诀:那些闪闪发光的宝藏mentor们
- Story of [Kun Jintong]: talk about Chinese character coding and common character sets
猜你喜欢

One hundred questions of image processing (11-20)

LeetCode 1557. The minimum number of points that can reach all points

~69 other ways to use icon fonts

Shell_ 04_ Shell script

Submit several problem records of spark application (sparklauncher with cluster deploy mode)

~83 form introduction

Audio and video development interview questions

字节跳动2022校招研发提前批宣讲会,同学们最关心的10个问题

One hundred questions of image processing (1-10)

字节跳动多篇论文入选 CVPR 2021,精选干货都在这里了
随机推荐
J'ai traversé le chemin le plus fou, le circuit cérébral d'un programmeur de saut d'octets
第三章 MapReduce框架原理
LeetCode 1637. The widest vertical area between two points without any point
Spark independent cluster dynamic online and offline worker node
How to generate six digit verification code
第5章 消费者组详解
was unable to send heartbeat
100张图训练1小时,照片风格随意变,文末有Demo试玩|SIGGRAPH 2021
Jedis
图像处理一百题(1-10)
MP4格式详解
「博士毕业一年,我拿下 ACL Best Paper」
The QT program compiled on CentOS lacks a MySQL driven solution
Fdog series (III): use Tencent cloud SMS interface to send SMS, write database, deploy to server, web finale.
LeetCode1556. Thousand separated number
Shell_ 02_ Text three swordsman
Li Kou leetcode 280 weekly match
字节跳动开源GAN模型压缩框架,算力最高节省97.8%丨ICCV 2021
~86m rabbit practice
LeetCode 1550. There are three consecutive arrays of odd numbers