Android Firebase连接-渐变错误

Android Firebase连接-渐变错误,android,firebase,gradle,android-gradle-plugin,Android,Firebase,Gradle,Android Gradle Plugin,我试图为firebase连接设置Android Studio。我按照指示行事,现在我就在这里: 所以我所做的是->添加应用插件:“com.google.gms.google服务”和 将'com.google.firebase:firebase core:16.0.0'编译到模块文件中,并在项目文件中编译classpath'com.google.gms:google services:4.0.0。现在我看到了红色下划线,我该如何修复它 以下是build.gradle(模块:App)中的代码:

我试图为firebase连接设置Android Studio。我按照指示行事,现在我就在这里:

所以我所做的是->添加
应用插件:“com.google.gms.google服务”
将'com.google.firebase:firebase core:16.0.0'
编译到模块文件中,并在项目文件中编译
classpath'com.google.gms:google services:4.0.0
。现在我看到了红色下划线,我该如何修复它

以下是build.gradle(模块:App)中的代码:

build.gradle(项目:FireBaseTest2):


我找到了解决办法。只需更改编译和实现,它将工作

我建议您使用基于的google服务的最新版本(4.0.1)。这有助于避免进一步的错误

build.grandle:

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

buildscript {

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


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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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


我认为这可能会帮助您复制请不要链接到代码的图像。最好将代码和错误信息复制到问题中,以便更容易阅读和搜索。我包含了代码。我理解正确吗。。。我必须手动将示例包含在错误消息中,版本与实现'com.android.support:appcompat-v7:27.1.1'相同?
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

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


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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

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


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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.ozan.firebasetest"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.google.firebase:firebase-core:16.0.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    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'