用Android Stduio
创建Flutter
项目的时候,会出现各种问题,踩了一个又一个,最后编译的时候可能会出现一直显示Running Gradle task 'assembleDebug'
然后就不动了,或者会显示Could not resolve io.flutter
等问题,归根结底是网络无法访问到Google
服务引起的,两种解决方案:
1.访问谷歌的服务的网络比较稳定
2.修改镜像源为国内的:
找到Flutte SDK
目录下的Flutter
打包配置文件flutter.gradle
路径为flutter\packages\flutter_tools\gradle\flutter.gradle
第一处配置:
buildscript { 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.5.0'}}
第二处配置:
class FlutterPlugin implements Plugin<Project> { //注释 // private static final String MAVEN_REPO = " //添加这行 private static final String MAVEN_REPO = " // The platforms that can be passed to the `--Ptarget-platform` flag. private static final String PLATFORM_ARM32 = "android-arm"; private static final String PLATFORM_ARM64 = "android-arm64"; private static final String PLATFORM_X86 = "android-x86"; private static final String PLATFORM_X86_64 = "android-x64"; // The ABI architectures. private static final String ARCH_ARM32 = "armeabi-v7a"; private static final String ARCH_ARM64 = "arm64-v8a"; private static final String ARCH_X86 = "x86"; private static final String ARCH_X86_64 = "x86_64";
第三处配置:
void addFlutterDependencies(buildType) { String flutterBuildMode = buildModeFor(buildType) if (!supportsBuildMode(flutterBuildMode)) { return } String repository = useLocalEngine() ? project.property('local-engine-repo') : MAVEN_REPOproject.rootProject.allprojects { repositories { maven {url repository} //添加 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
项目下的android
下的build.gradle:
buildscript { ext.kotlin_version = '1.3.50' 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.5.0' 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' } } }
修改完成后,再build,就可以正常构建了!!!
点击查看更多内容
2人点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦