簡體   English   中英

我的構建配置為在項目存儲庫上設置存儲庫,build.gradle 構建文件添加了存儲庫“Google”

[英]My build is configured to settings repositories over project repositories, repository ‘Google’ was added by build.gradle build file

我已經厭倦了使用答案來解決像我這樣的另一個問題,但我不明白也不認為它回答了我的問題構建被配置為更喜歡設置存儲庫而不是項目存儲庫但是構建文件添加了存儲庫“谷歌”' build.gradle' 我正在使用最新版本的 Android Studio

這是我的 build.gradle 項目

 // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        // Make sure that you have the following two repositories
        google()  // Google's Maven repository

        mavenCentral()  // Maven Central repository

    }
    dependencies {
        // Add the dependency for the Google services Gradle plugin
        classpath 'com.google.gms:google-services:4.3.13'

    }
}

allprojects {
    repositories {
        // Make sure that you have the following two repositories
        google()  // Google's Maven repository

        mavenCentral()  // Maven Central repository

    }
}
plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
}

這是我的 build.gradle 模塊

    plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
}

android {
    namespace 'com.example.destination'
    compileSdk 32

    defaultConfig {
        applicationId "com.example.destination"
        minSdk 17
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'com.google.android.material:material:1.7.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation platform('com.google.firebase:firebase-bom:31.1.1')
    implementation 'com.google.firebase:firebase-analytics'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    classpath 'com.android.tools.build:gradle:7.3.1'
}

最后這是我的 settings.gradle(項目設置)代碼

    pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    //repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "Destination"
include ':app'

如果有解決方案,請您一步一步地告訴我如何操作,因為我以前從未這樣做過。 我正在嘗試將 Firebase 添加到我的應用程序

您已將其配置為在將回購添加到項目 build.gradle 時失敗:

    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)

然后將google()添加到根目錄(項目)build.gradle 文件中:

allprojects {
    repositories {
        google() 
        mavenCentral() 

    }
}

^ 刪除那個

因為在您的 settings.gradle 中,您無論如何都在這里聲明它們:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 
    repositories {
        google()    // no need to declare this in `allProjects` if its declared here 
        mavenCentral()
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM