Flutter: Firestore component is not present

后端 未结 5 1611
心在旅途
心在旅途 2020-12-22 07:00

I have a problem with Firestore database under Flutter. I have done everything, what the package setup documentation says, looked into 2-3 finished public application, and t

5条回答
  •  死守一世寂寞
    2020-12-22 07:56

    Okay, so I figured out from looking into an other problem.

    I don't know if I was the only one who didn't know, but because of a new gradle update,

    classpath 'com.google.gms:google-services:3.2.1'

    was deprecated. I don't really know how the hell, but this caused, that somehow Flutter didn't get the instance right, and throw a nullPointer exception. If anyone has the same problem ( debug console show some deprecated warning), you should change the

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

    lines in android/build.gradle to

    buildscript {
        repositories {
                google()
                jcenter()
            }
    
        dependencies {
                classpath 'com.android.tools.build:gradle:3.3.0'
                classpath ('com.google.gms:google-services:3.2.1') {
                    exclude group: 'com.google.guava', module: 'guava-jdk5'
           }
        }
    }
    

    I don't really know, why a deprecated form of dependency include caused such a problem, but this change worked for me, and I hope it helps others too. Besides that, I don't think this should cause such a wasted day, as a lot a of documentation should include this fix for the devs.

提交回复
热议问题