ERROR: Could not find com.google.gms.google-services:4.2.0

ERROR: Could not find com.google.gms.google-services:4.2.0

我正在尝试将 Firebase crashlytics 添加到现有项目(不是我开发的)。我一直收到错误

ERROR: Could not find com.google.gms.google-services:4.2.0:.
Required by:
    project :
Search in build.gradle files

我已经完成了所有(或大部分)要求添加 maven { url 'https://maven.google.com' } 的解决方案,其中 none 有效。所有解决方案都出现上述错误。

请不要让我开发的其他项目在相同的情况下工作正常build.gradle但不确定为什么这个项目给我带来噩梦。

project level build.gradle

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

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        // Check for v3.1.2 or higher
        classpath 'com.google.gms.google-services:4.2.0'

        // Add dependency
        classpath 'io.fabric.tools:gradle:1.28.0'

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

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        //maven { url 'https://maven.google.com' }

    }
}

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

app level build.gradle

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.architgoyal.startup_prototype"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 8
        versionName "1.6.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        debug {
            buildConfigField "java.util.Date", "BUILD_TIME", "new java.util.Date(" + System.currentTimeMillis() + "L)"
        }
        release {
            buildConfigField "java.util.Date", "BUILD_TIME", "new java.util.Date(" + System.currentTimeMillis() + "L)"
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    //implementation 'com.google.firebase:firebase-core:16.0.8'

    // Add dependency
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
    // barcode reader library
    implementation 'info.androidhive:barcode-reader:1.1.5'
    // google vision library
    implementation 'com.google.android.gms:play-services-vision:11.0.2'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.github.GoodieBag:Pinview:v1.3'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'me.dm7.barcodescanner:zxing:1.8.4'
    implementation 'com.android.volley:volley:1.0.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    annotationProcessor 'com.jakewharton:butterknife:6.1.0'
    implementation 'com.jakewharton:butterknife:6.1.0'
    implementation 'com.jaredrummler:material-spinner:1.3.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

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

您在 classpath 语句中有错字。

这个

classpath 'com.google.gms.google-services:4.2.0'

应该是

classpath 'com.google.gms:google-services:4.2.0'

这是文档错误,应该如下所示

classpath 'com.google.gms:google-services:4.2.0'

问题是

classpath 'com.google.gms.google-services:4.2.0'

.在gms.google之间应该是: