Firebase云Firestore - android应用程序连接。

时间:2021-01-17 23:12:38

I am trying to connect the firestore db to my android application. I followed instructions but I can not create and instance of a Firestore db because "FirebaseFirestore" symbol can not resolved error pops up.

我正在尝试将firestore db连接到我的android应用程序。我遵循了指令,但我不能创建和实例一个Firestore db,因为“FirebaseFirestore”符号不能解决错误。

Here is my dependencies at build gradle (app) file:

以下是我在build gradle (app)文件中的依赖关系:

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

and I also added this line to end of the build gradle file :

我还将这条线添加到build gradle文件的末尾:

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

应用插件:“com.google.gms.google-services”

and these are the dependencies at build gradle (project) file :

这些是构建gradle(项目)文件的依赖项:

dependencies {
            classpath 'com.android.tools.build:gradle:3.0.1'
            classpath 'com.google.gms:google-services:3.2.0'
             // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }

and google's maven repository is defined like this:

谷歌的maven存储库定义如下:

 allprojects {
        repositories {
            google()
            jcenter()

        }

What am i missing ? I also added google-services.json file.

我错过了什么?我还添加了谷歌服务。json文件。

3 个解决方案

#1


1  

For Firebase database and its references use:

对于Firebase数据库及其引用使用:

compile 'com.google.firebase:firebase-database:11.8.0'

#2


1  

Try this:-

试试这个:

dependencies {  
    implementation 'com.google.firebase:firebase-database:11.8.0'
    // ...
}

Follow the documentation here

遵循这里的文档

#3


0  

Just Add this gradle in Dependencies

只需要在依赖项中添加这个级别。

dependencies {  
    implementation 'com.google.firebase:firebase-firestore:15.0.0'
    // ...
}

#1


1  

For Firebase database and its references use:

对于Firebase数据库及其引用使用:

compile 'com.google.firebase:firebase-database:11.8.0'

#2


1  

Try this:-

试试这个:

dependencies {  
    implementation 'com.google.firebase:firebase-database:11.8.0'
    // ...
}

Follow the documentation here

遵循这里的文档

#3


0  

Just Add this gradle in Dependencies

只需要在依赖项中添加这个级别。

dependencies {  
    implementation 'com.google.firebase:firebase-firestore:15.0.0'
    // ...
}