【错误记录】Flutter 应用运行卡在 Running Gradle task ‘assembleDebug‘... ( 配置阿里云 Maven 仓库镜像 )

文章目录





一、 报错信息



运行 Flutter 应用 , 会一直卡在 Running Gradle task ‘assembleDebug’… 步骤 ;

【错误记录】Flutter 应用运行卡在 Running Gradle task ‘assembleDebug‘... ( 配置阿里云 Maven 仓库镜像 )

此时如果中断网络 , 就可以看到卡住的原因 , 卡在了下载运行环境和依赖库的步骤 , jcenter 下载速度太慢 ;

Launching lib\main.dart on Pixel 2 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not download kotlin-compiler-embeddable.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.50)
      > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.3.50/kotlin-compiler-embeddable-1.3.50.jar'.
         > Connection reset

* 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 5m 27s
Finished with error: Gradle task assembleDebug failed with exit code 1




二、 解决方案





1、 解决方案 1


* , 快速解决 , 连接香港就可以快速下载相关的依赖库 , 不用跑太远 ;



2、 解决方案 2


看别人也有配置阿里云镜像的 , 没试过 , 作为备选方案记录下来 ;

配置阿里云镜像 :

    repositories {
        google()
        jcenter()
    }

替换为 :

    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' }
    }

有 2 2 2 个文件 3 3 3 处需要替换的地方 :


工程/android/build.gradle 目录下 , buildscript 与 allprojects 中两个配置都要修改 ;

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

【错误记录】Flutter 应用运行卡在 Running Gradle task ‘assembleDebug‘... ( 配置阿里云 Maven 仓库镜像 )


Flutter 配置文件中配置阿里云镜像 , 在 flutter\packages\flutter_tools\gradle\flutter.gradle 中进行如下修改 , 将 buildscript 下的 maven 仓库替换成阿里云镜像 ;

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
    }
}

【错误记录】Flutter 应用运行卡在 Running Gradle task ‘assembleDebug‘... ( 配置阿里云 Maven 仓库镜像 )

上一篇:Spring5.2.x源码导入idea


下一篇:HPE 篇一