将 com.google.gms:google-services:4.3.10 添加为类路径到项目 build.gradle 文件后,下载时出现问题

问题描述 投票:0回答:1

在尝试将我的应用程序连接到 firebase 后,我开始收到此错误。

这是我在 gradle 构建后收到的错误消息

无法获取“https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.3.10/google-services-4.3.10.pom”。从服务器收到状态代码 405:方法不允许

项目build.gradle文件内容

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()

    }

    dependencies {
        classpath "com.android.tools.build:gradle:7.0.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
        classpath 'com.google.gms:google-services:4.3.10'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {

    repositories {
        // Check that you have the following line (if not, add it):
        google()  // Google's Maven repository
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app/build.gradle 文件内容

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

//apply plugin: 'com.google.gms.google-services'

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.daniel_sogbey.marmap"
        minSdk 21
        targetSdk 31
        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
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildToolsVersion '31.0.0'
}

dependencies {

    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    implementation platform('com.google.firebase:firebase-bom:28.4.2')
    implementation 'com.google.firebase:firebase-analytics-ktx'
}

googleServices { disableVersionCheck = true }

android firebase android-gradle-plugin google-play-services
1个回答
1
投票

您的 Gradle 文件看起来不错,但您的系统似乎无法联系 Google 存储库。

确保您没有运行阻止访问的防火墙。

© www.soinside.com 2019 - 2024. All rights reserved.