flutter学习(一)配置环境与解决可能会出现的问题

mac2022-06-30  20

配置环境操作步骤可按这篇文章 https://book.flutterchina.club/chapter1/install_flutter.html

但是按照操作,也会出现各种配置问题

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0 Syncing files to device failed Plugin with id 'kotlin-android' not found. ProcessException: Process “C:\..\myapp\android\gradlew.bat” exited abnormally:

耗费了大量时间,才总算解决 现在给一揽子解决方案

步骤一

保证flutter链接上 flutter doctor 出现4个√即可保证flutter已经ok

步骤二

打开build.gradle 使用阿里云镜像

buildscript { ext.kotlin_version = '1.2.71' repositories { // google() // jcenter() maven{ url 'https://maven.aliyun.com/repository/google' } maven{ url 'https://maven.aliyun.com/repository/jcenter' } maven{url 'http://maven.aliyun.com/nexus/content/groups/public'} } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { // google() // jcenter() maven{ url 'https://maven.aliyun.com/repository/google' } maven{ url 'https://maven.aliyun.com/repository/jcenter' } maven{url 'http://maven.aliyun.com/nexus/content/groups/public'} } }

步骤三

打开…\flutter\packages\flutter_tools\gradle\flutter.gradle 修改buildscript{}如下

buildscript { repositories { maven{ url 'https://maven.aliyun.com/repository/google' } maven{ url 'https://maven.aliyun.com/repository/jcenter' } maven{ url 'http://maven.aliyun.com/nexus/content/groups/public' } } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' } }

然后运行,注意classpath 需要3.2.1版本,一开始我的是3.5.0版本,但是实测有误,最好改成3.2.1

最后,在某些模拟器上可能会闪退(如网易mumu,又耗我一小时!!!) 在我手机上可以运行,证明配置没问题了

android studio将显示如下 flutter运行成功

最新回复(0)