android - 错误 : Could not find com. google.gms.google-services :4. 2.0

标签 android firebase google-play-services crashlytics-android

我正在尝试将 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 的所有(或大部分)解决方案' } 并且它们都不起作用。对于所有解决方案,我都收到上述错误。

请不要让我开发的其他项目使用相同的 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'

关于android - 错误 : Could not find com. google.gms.google-services :4. 2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55416111/

相关文章:

java - 在 Android 应用程序中打开链接而不是打开 Web View

android - getAssets() 在 eclipse 中显示错误

java - 在android中解析asynctask内的json

javascript - 列出具有自定义声明的用户的最佳方式

javascript - NextJS 与 Firebase 云功能

android - Auth 类在哪里——Google Play Services 8.3.0

android - java.lang.IllegalStateException : Could not execute method of the activity with Android 错误

android - Play 服务的 Firebase 低于 9

android - 我可以使用 Play Services 9.2 扫描 iBeacons 吗?

android - Google Play Services 使 apk 太大