精华 flutter run的时候提示Gradle 无法从 Maven 中央仓库下载 AndroidX 依赖

flutter run的时候提示下面错误,提示Gradle 无法从 Maven 中央仓库下载 AndroidX 依赖。这些依赖版本(如 lifecycle-common:2.7.0)可能存在或者被重定向了

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find androidx.lifecycle:lifecycle-common:2.7.0.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/androidx/lifecycle/lifecycle-common/2.7.0/lifecycle-common-2.7.0.pom
       - https://storage.googleapis.com/download.flutter.io/androidx/lifecycle/lifecycle-common/2.7.0/lifecycle-common-2.7.0.pom
     Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262
   > Could not find androidx.lifecycle:lifecycle-common-java8:2.7.0.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/androidx/lifecycle/lifecycle-common-java8/2.7.0/lifecycle-common-java8-2.7.0.pom
       - https://storage.googleapis.com/download.flutter.io/androidx/lifecycle/lifecycle-common-java8/2.7.0/lifecycle-common-java8-2.7.0.pom
     Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262
   > Could not find androidx.lifecycle:lifecycle-process:2.7.0.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/androidx/lifecycle/lifecycle-process/2.7.0/lifecycle-process-2.7.0.pom
       - https://storage.googleapis.com/download.flutter.io/androidx/lifecycle/lifecycle-process/2.7.0/lifecycle-process-2.7.0.pom
     Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262
   > Could not find androidx.lifecycle:lifecycle-runtime:2.7.0.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/androidx/lifecycle/lifecycle-runtime/2.7.0/lifecycle-runtime-2.7.0.pom
       - https://storage.googleapis.com/download.flutter.io/androidx/lifecycle/lifecycle-runtime/2.7.0/lifecycle-runtime-2.7.0.pom
     Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262
   > Could not find androidx.fragment:fragment:1.7.1.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/androidx/fragment/fragment/1.7.1/fragment-1.7.1.pom
       - https://storage.googleapis.com/download.flutter.io/androidx/fragment/fragment/1.7.1/fragment-1.7.1.pom
     Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262
   > Could not find androidx.annotation:annotation:1.8.0.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/androidx/annotation/annotation/1.8.0/annotation-1.8.0.pom
       - https://storage.googleapis.com/download.flutter.io/androidx/annotation/annotation/1.8.0/annotation-1.8.0.pom
     Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262
   > Could not find androidx.tracing:tracing:1.2.0.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/androidx/tracing/tracing/1.2.0/tracing-1.2.0.pom
       - https://storage.googleapis.com/download.flutter.io/androidx/tracing/tracing/1.2.0/tracing-1.2.0.pom
     Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262
   > Could not find androidx.core:core:1.13.1.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/androidx/core/core/1.13.1/core-1.13.1.pom
       - https://storage.googleapis.com/download.flutter.io/androidx/core/core/1.13.1/core-1.13.1.pom
     Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262
   > Could not find androidx.window:window-java:1.2.0.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/androidx/window/window-java/1.2.0/window-java-1.2.0.pom
       - https://storage.googleapis.com/download.flutter.io/androidx/window/window-java/1.2.0/window-java-1.2.0.pom
     Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262

* 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 58s
Running Gradle task 'assembleDebug'...                             59.7s
Error: Gradle task assembleDebug failed with exit code 1

更多关于flutter run的时候提示Gradle 无法从 Maven 中央仓库下载 AndroidX 依赖的实战教程也可以访问 https://www.itying.com/category-92-b0.html

1 回复

更多关于flutter run的时候提示Gradle 无法从 Maven 中央仓库下载 AndroidX 依赖的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html


解决方法:打开你项目中的 android/build.gradle 文件 ,加上阿里云镜像仓库


gradle
allprojects {
    repositories {
        // 1. 阿里云镜像仓库(国内开发环境首选,速度稳定)
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/public' }
        // 2. 官方的Google和Maven中央仓库
        google()
        mavenCentral()
       
    }
}

20260120210004_123_14.jpg

回到顶部