我没有看到 Allprojects 存储库

sur*_*rya 13 firebase android-studio

Firebase 未连接,并且显示错误,例如无法解析 Android 应用程序模块的 Gradle 配置。解决 gradle 构建问题和/或重新同步。

有些人说要删除 jcenter() ..但是在我的应用程序 gradle 中我没有看到任何所有项目存储库这是我的应用程序built.gradle ...

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.0"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}`
Run Code Online (Sandbox Code Playgroud)

小智 14

我在添加“maven { url 'https://jitpack.io' }”时遇到了同样的问题,
我通过将其添加到settings.gradle文件中解决了这个问题,如下所示,

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven { url 'https://jitpack.io' }
    }
}
Run Code Online (Sandbox Code Playgroud)


Ang*_*Koh 11

当尝试使用 gradle 7.0.2 添加“maven { url 'https://jitpack.io' }”的存储库时,我遇到了同样的问题。

当我添加 allprojects 块时:-

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误。

评估根项目“PetShop List”时出现问题。

构建配置为更喜欢设置存储库而不是项目存储库,但存储库“Google”是由构建文件“build.gradle”添加的

原因是settings.gradle中的 dependencyResolutionManagement 块。

要解决此问题,只需转到“settings.gradle”文件注释整个“dependencyResolutionManagement”块即可。

然后重新同步您的项目,它应该可以工作。

  1. 解决方案1

在此输入图像描述

  1. 解决方案2

在此输入图像描述

在settings.gradle中像这样改变

import org.gradle.api.initialization.resolve.RepositoriesMode

dependencyResolutionManagement {

    repositories {
        google()
//    notice here -------------------------
        repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
        //    notice here -------------------------
        mavenCentral()
        maven { url 'https://jitpack.io' }
        jcenter() // Warning: this repository is going to shut down soon
    }
}
rootProject.name = "My Application"
include ':app'

Run Code Online (Sandbox Code Playgroud)


小智 5

转到setting.gradle文件。然后添加maven { url 'https://jitpack.io' }这一行。

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven { url 'https://jitpack.io' }
    }
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

在此输入图像描述