Firebase gradle build使用最新的11.8.0版本获取错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Firebase gradle build使用最新的11.8.0版本获取错误相关的知识,希望对你有一定的参考价值。

使用Firebase API时,android studio gradle build会出错。我使用了google doc中的所有参数。它正在使用示例应用程序。但是,如果我将相同的库添加到我的应用程序gradle build中,则显示此错误。

在构建gradle时,它在Android studio 3.0.1中会出现这样的错误:

Error:Cause: inconsistent module metadata found. Descriptor: com.google.gms:google-services:3.2.0 Errors: bad group: expected='com.google.gms.' found='com.google.gms'

这里我要添加root gradle文件:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'me.tatarka:gradle-retrolambda:3.3.0-beta4'
        classpath 'com.google.gms.:google-services:3.2.0'

    }
}

allprojects {
    repositories {
        google()
        jcenter()

        mavenCentral()
        maven { url 'https://jitpack.io' }

        maven {
            url 'https://repo.adobe.com/nexus/content/repositories/releases/'
        }

        maven {
            url 'http://maven.localytics.com/public'
        }
        maven { url 'https://maven.google.com' }
    }
}

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

还有app gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'


android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "co.hushush.user"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 5
        versionName "1.4-Beta"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        manifestPlaceholders = [appPackageName: "${applicationId}"]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility org.gradle.api.JavaVersion.VERSION_1_8
        targetCompatibility org.gradle.api.JavaVersion.VERSION_1_8
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/rxjava.properties'
        pickFirst 'AndroidManifest.xml'

    }
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
    dexOptions {
        jumboMode true
    }
    buildToolsVersion '27.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-vector-drawable:27.1.0'
    implementation 'com.android.support:support-v4:27.1.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'io.reactivex.rxjava2:rxjava:2.1.0'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    // For easy preference manager
    compile 'com.pixplicity.easyprefs:library:1.9.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.android.support:cardview-v7:27.1.0'
    implementation 'com.android.support:recyclerview-v7:27.1.0'
    implementation 'android.arch.persistence.room:runtime:1.0.0'
    annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
    compile 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
    compile 'com.adobe.creativesdk.foundation:auth:0.9.2006-5'
    compile 'com.adobe.creativesdk:image:4.8.4'
    compile 'com.localytics.android:library:3.8.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'com.asksira.android:loopingviewpager:1.1.0'
    compile 'com.romandanylyk:pageindicatorview:1.0.0'
    compile 'com.github.bumptech.glide:glide:4.6.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.paytm.pgsdk:pgsdk:1.0.6'
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'com.github.MdFarhanRaja:SearchableSpinner:1.9'
}

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

改变这个:

'com.google.gms.:google-services:3.2.0'

对此:

'com.google.gms:google-services:3.2.0'

point(.)之前没有:

以上是关于Firebase gradle build使用最新的11.8.0版本获取错误的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Unity 中使用 Gradle

颤动的firebase错误“失败:构建失败并出现异常”

gradle build 时 Android 打包失败,错误为 3

com.android.tools.build:gradle:1.1.0 怎么升级

Error:Could not find com.android.tools.build:gradle:2.14.1.

为啥即使源代码没有变化,Gradle 的“构建”任务也不是最新的?