错误:找不到com.google.gms.google-services:4.2.0

时间:2019-03-29 11:07:34

标签: 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一起正常工作,但不确定为什么这个项目给我带来噩梦。

  

项目级别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
}
  

应用程序级别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'

2 个答案:

答案 0 :(得分:19)

classpath语句中有错字。

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

应该是

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

答案 1 :(得分:0)

这是文档错误,应该像下面一样

todo : () => import ('./modules/todo') <<<<<< Fail

问题是

classpath 'com.google.gms:google-services:4.2.0'
在gms.google之间

classpath 'com.google.gms.google-services:4.2.0' 应该是.