简记:一个flutter构建错误A problem occurred configuring project ‘:smart_auth‘. > Could not res

Flutter笔记
标题2

本文地址https://blog.csdn.net/qq_28550263/article/details/133314522



1. 错误内容

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':smart_auth'.
> Could not resolve all files for configuration ':smart_auth:classpath'.
   > Could not download kotlin-gradle-plugin-1.7.20-gradle71.jar (org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.7.20/kotlin-gradle-plugin-1.7.20-gradle71.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.7.20/kotlin-gradle-plugin-1.7.20-gradle71.jar'.
            > Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.108.215] failed: Connection timed out: no further information
> Failed to notify project evaluation listener.
   > Could not get unknown property 'android' for project ':smart_auth' of type org.gradle.api.Project.
   > Could not get unknown property 'android' for project ':smart_auth' of type org.gradle.api.Project.

* 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 2m 37s
Running Gradle task 'assembleDebug'...                            158.6s
[!] Gradle threw an error while downloading artifacts from the network.
Retrying Gradle Build: #1, wait time: 100ms
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!

2. 问题分析

这个错误信息看起来是Gradle构建过程中出现了问题,具体来说有以下几个问题:

  1. Gradle下载依赖时出现了超时错误。这可能是由于网络问题或Maven中央仓库的访问问题引起的。为了解决这个问题,可以尝试切换到国内的Maven镜像,或者检查 网络连接 是否正常。

  2. 项目 ‘:smart_auth’ 中的 Gradle 配置问题。错误信息中提到了无法获取属性 ‘android’,这通常意味着Gradle配置文件中存在错误。需要检查项目 ‘:smart_auth’ 的 Gradle 构建文件,确保其中的配置正确。

3. 解决方案

为了解决这些问题,可以尝试以下步骤:

  1. 检查网络连接:确保计算机可以正常访问互联网,并且没有网络防火墙或代理服务器阻止Gradle的访问。可以尝试使用浏览器或命令行工具测试对Maven中央仓库的访问。

  2. 切换到国内镜像:可以考虑切换到国内的Maven镜像,以加快依赖下载速度。在项目的 build.gradle 文件中的 repositories 部分添加一个国内镜像,例如,使用阿里云镜像:

repositories {
    maven { url 'https://maven.aliyun.com/repository/central' }
    // 其他仓库配置...
}

在这里插入图片描述

  1. 检查 ‘:smart_auth’ 项目的Gradle配置:打开 ‘:smart_auth’ 项目的 build.gradle 文件,确保其中的Gradle配置正确。特别关注是否有不正确的Android相关配置,因为错误信息中提到了无法获取属性 ‘android’。

  2. 清理和重新构建:运行以下命令清理Gradle构建并重新构建项目:

flutter clean
flutter pub get
flutter run

我的切换到阿里云镜像就解决了,祝你成功~

猜你喜欢

转载自blog.csdn.net/qq_28550263/article/details/133314522
今日推荐