颤振:不存在Firestore组件 [英] Flutter: Firestore component is not present

查看:58
本文介绍了颤振:不存在Firestore组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Flutter下的Firestore数据库有问题.我已经按照包安装文档中的说明完成了所有工作,调查了2-3个完成的公共应用程序,并尝试像其他人一样使用该包.我什至尝试实现本机Firestore初始化,因为我认为问题出在平台方面,但是应用程序仍然可以获取

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 tried to use the package as others use. I even tried to implement native Firestore initialization, because i think the problem is on the platform side, but still, the application get

java.lang.NullPointerException:不存在Firestore组件.

java.lang.NullPointerException: Firestore component is not present.

当我尝试使用Firestore实例时.

when i try to use the Firestore instance.

在我设置的project/build.gradle中

In project/build.gradle I set

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

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

用于依赖项,也可以导入

for dependency and also imported

'com.google.firebase:firebase-core:16.0.1'

'com.google.firebase:firebase-core:16.0.1'

'com.android.support:multidex:1.0.3'

'com.android.support:multidex:1.0.3'

我的应用程序文件夹中有google-service.json.

I have the google-service.json in my app folder.

有人可以帮助我解决这个问题吗?我浪费了一天,却一无所获. 非常感谢!

Can anyone help me with this problem? I wasted a day, and still nothing. Thanks a lot!

推荐答案

好的,所以我想出了解决其他问题的方法.

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

我不知道我是否是唯一一个不认识的人,但是由于新的gradle更新,

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'

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

已被弃用.我真的不知道这是怎么回事,但是这造成了Flutter无法正确获取实例,并抛出nullPointer异常. 如果有人遇到相同的问题(调试控制台显示一些已弃用的警告),则应更改

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'

     }
  }
}

android/build.gradle中的

行要

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.

这篇关于颤振:不存在Firestore组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆