Android Firebase 连接 - Gradle 错误

标签 android firebase gradle android-gradle-plugin

我尝试将我的 Android Studio 设置为 Firebase 连接。我按照说明进行操作,这就是我现在所在的位置:

build Gradle Project File

build Gradle Error

Message when i hover other the red underlined implementation

所以我所做的是-> 添加apply plugin: 'com.google.gms.google-services'compile 'com.google.firebase:firebase-core:16.0.0'进入模块文件和classpath 'com.google.gms:google-services:4.0.0 ' 在项目文件中。现在我看到红色下划线,我该如何解决?

这是来自 build.gradle 的代码(模块:应用程序):

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 {
    compile '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'

build.gradle(项目:FireBaseTest2):
// 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
}

最佳答案

我找到了解决方案。只需使用实现更改编译,它就会起作用!

关于Android Firebase 连接 - Gradle 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50726037/

相关文章:

没有 Intent 过滤器的 Android BroadcastReceiver

java - Android:如何让后续例程等待ObjectAnimator?

java - JNI : Calling a java method from C periodically is not working

android - 不需要在 Manifest 中注册 Activity 基类?

javascript - 从 Javascript 的 Firebase 数据库中的查询结果中获取特定子项的值

database - 我可以在 Cloud Firestore 中将集合设置为仅追加吗?

ios - Xcode 8.3 链接器警告

java - 将多项目本身添加为另一个项目中的依赖项

build - 如何在Gradle中的依赖项组上指定属性?

java - 在IntelliJ IDEA中运行Gradle测试时的"No tests found for given includes"