美文网首页
Flutter 在Android studio运行时卡在Runn

Flutter 在Android studio运行时卡在Runn

作者: sampson666888 | 来源:发表于2023-10-27 15:08 被阅读0次

Android studio用simulator运行flutter项目时候,一直卡在Running Gradle task 'assembleDebug'...
这是因为Android studio运行项目时需要请求部分资源,而请求外网资源,需要翻墙或者换源

解决方法:更换阿里源

1.1 修改Flutter SDK安装目录下的文件:flutter/packages/flutter_tools/gradle/flutter.gradle(如果找不到,那就修改这个flutter/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy)

repositories {
// google()
// mavenCentral()
maven { url '[https://maven.aliyun.com/repository/google'](https://links.jianshu.com/go?to=https%3A%2F%2Fmaven.aliyun.com%2Frepository%2Fgoogle%27) }
maven { url '[https://maven.aliyun.com/repository/jcenter'](https://links.jianshu.com/go?to=https%3A%2F%2Fmaven.aliyun.com%2Frepository%2Fjcenter%27) }
maven { url '[https://maven.aliyun.com/nexus/content/groups/public'](https://links.jianshu.com/go?to=https%3A%2F%2Fmaven.aliyun.com%2Fnexus%2Fcontent%2Fgroups%2Fpublic%27) }
}

class FlutterPlugin implements Plugin<Project> {
// private static final String DEFAULT_MAVEN_HOST = "[https://storage.googleapis.com](https://links.jianshu.com/go?to=https%3A%2F%2Fstorage.googleapis.com)";
private static final String DEFAULT_MAVEN_HOST = "[https://storage.flutter-io.cn](https://links.jianshu.com/go?to=https%3A%2F%2Fstorage.flutter-io.cn)";
...}

1.2. 修改Flutter SDK安装目录下的文件:flutter\packages\flutter_tools\gradle/resolve_dependencies.gradle

repositories {
// google()
// mavenCentral()
maven { url '[https://maven.aliyun.com/repository/google'](https://links.jianshu.com/go?to=https%3A%2F%2Fmaven.aliyun.com%2Frepository%2Fgoogle%27) }
maven { url '[https://maven.aliyun.com/repository/jcenter'](https://links.jianshu.com/go?to=https%3A%2F%2Fmaven.aliyun.com%2Frepository%2Fjcenter%27) }
maven { url '[https://maven.aliyun.com/nexus/content/groups/public'](https://links.jianshu.com/go?to=https%3A%2F%2Fmaven.aliyun.com%2Fnexus%2Fcontent%2Fgroups%2Fpublic%27) }
maven {
// url "$storageUrl/download.flutter.io"
url "[https://storage.flutter-io.cn/download.flutter.io](https://links.jianshu.com/go?to=https%3A%2F%2Fstorage.flutter-io.cn%2Fdownload.flutter.io)"
}
}

2.1修改Flutter项目目录的文件:android\build.gradle

buildscript {
ext.kotlin_version = '1.6.10'
repositories {
// google()
// mavenCentral()
maven { url '[https://maven.aliyun.com/repository/google'](https://links.jianshu.com/go?to=https%3A%2F%2Fmaven.aliyun.com%2Frepository%2Fgoogle%27) }
maven { url '[https://maven.aliyun.com/repository/jcenter'](https://links.jianshu.com/go?to=https%3A%2F%2Fmaven.aliyun.com%2Frepository%2Fjcenter%27) }
maven { url '[https://maven.aliyun.com/nexus/content/groups/public'](https://links.jianshu.com/go?to=https%3A%2F%2Fmaven.aliyun.com%2Fnexus%2Fcontent%2Fgroups%2Fpublic%27) }
}

...

allprojects {
repositories {
// google()
// mavenCentral()
maven { url '[https://maven.aliyun.com/repository/google'](https://links.jianshu.com/go?to=https%3A%2F%2Fmaven.aliyun.com%2Frepository%2Fgoogle%27) }
maven { url '[https://maven.aliyun.com/repository/jcenter'](https://links.jianshu.com/go?to=https%3A%2F%2Fmaven.aliyun.com%2Frepository%2Fjcenter%27) }
maven { url '[https://maven.aliyun.com/nexus/content/groups/public'](https://links.jianshu.com/go?to=https%3A%2F%2Fmaven.aliyun.com%2Fnexus%2Fcontent%2Fgroups%2Fpublic%27) }
}
}

相关文章

网友评论

      本文标题:Flutter 在Android studio运行时卡在Runn

      本文链接:https://www.haomeiwen.com/subject/tvzuidtx.html