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

配置环境操作步骤可按这篇文章
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运行成功

全部评论

相关推荐

后端转测开第一人:再怎么劝退也没用的 某些群体总以为在一个幸存者偏差的软件上看见了极少数秋招上岸某个大厂的个例就幻想上了 事实上自己打开ssob沟通1000+连个小厂面试都没
点赞 评论 收藏
分享
09-14 20:51
四川大学 Java
慢热的鲸鱼在学习:985加粗就行了,第二个项目来不及准备也没事,省的写了问你你还不会。你只需准备面试八股和项目场景,剩下的交给985。即使面不过也没事,面试经验是最重要的,你现在不缺时间
简历中的项目经历要怎么写
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务