google-services插件无法检测到com.google.android.gms或com.google.firebase的任何版本 - 奇怪的行为

App*_*evo 7 android firebase google-play-services android-studio android-gradle-plugin

我有4个模块的项目:

  • app(主要)
  • 共LIB
  • C
  • d

我已将firebase正确设置为以下状态:https://firebase.google.com/docs/android/setup

在我的app模块中,我不使用任何其他库,只使用模块依赖:

dependencies {
    debugCompile project(path: ':common-lib', configuration: 'debug')
    releaseCompile project(path: ':common-lib', configuration: 'release')
}
Run Code Online (Sandbox Code Playgroud)

在我的common-lib模块中,我使用firebase库:

dependencies {
    (...)
    compile 'com.google.firebase:firebase-core:11.2.0'
    compile 'com.google.firebase:firebase-crash:11.2.0'
    compile 'com.google.firebase:firebase-messaging:11.2.0'
    compile 'com.google.firebase:firebase-config:11.2.0'
    compile 'com.google.firebase:firebase-ads:11.2.0'
}
Run Code Online (Sandbox Code Playgroud)

在这种情况下项目编译,但我收到了消息:

google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 9.0.0 will be used.
please apply google-services plugin at the bottom of the build file.
Run Code Online (Sandbox Code Playgroud)

当我将common-lib firebase依赖项复制到我的app模块时,消息消失了.

这是一个错误吗?我做错了吗?我的应用程序输出文件是否包含正确的11.2.0版本的firebase库,或者消息是否为9.0.0?


编辑

project build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
            // Alternative URL is 'https://dl.google.com/dl/android/maven2/'
        }
        maven { url 'https://jitpack.io' }
    }
}
Run Code Online (Sandbox Code Playgroud)

app模块build.gradle

apply plugin: 'com.android.application'

android {
    (...)
}


dependencies {

    debugCompile project(path: ':common-lib', configuration: 'debug')
    debugTestCompile project(path: ':common-lib', configuration: 'debugTest')
    releaseCompile project(path: ':common-lib', configuration: 'release')

}

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

common-lib moudle build.gradle

apply plugin: 'com.android.library'


android {
    (...)
}
dependencies {
    (...)
    //firebase
    compile 'com.google.firebase:firebase-core:11.2.0'
    compile 'com.google.firebase:firebase-crash:11.2.0'
    compile 'com.google.firebase:firebase-messaging:11.2.0'
    compile 'com.google.firebase:firebase-config:11.2.0'
    compile 'com.google.firebase:firebase-ads:11.2.0'
}
Run Code Online (Sandbox Code Playgroud)

Vya*_*lav 0

你有没有尝试添加这个:

apply plugin: 'com.google.gms.google-services'在 gradle 文件的根级别?