成功通过Google身份验证后,使用实时数据库时应用程序崩溃 [英] after successful google authentication, app crashes while using real time database

查看:88
本文介绍了成功通过Google身份验证后,使用实时数据库时应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,成功登录Google后,当您获得Firebase实时数据库的实例时,该应用就会崩溃.

In my app, after a successful login with Google, it crashes when you get an instance of a firebase realtime database.

在我的代码中,Google标牌可以正常工作 之后,还有一些参数可以获取用户信息 还有一个按钮,我已将其设置为onClickListener以便将用户数据上传到实时数据库中.

In my code, the Google sign works fine after that and there are parameters to get user info and a button on which I have set an onClickListener to upload user data in a realtime database.

onCreate 我有方法

 company_name = (EditText) findViewById(R.id.ip_company_name);
 mdatabase = FirebaseDatabase.getInstance().getReference();
 val_btn = (Button) findViewById(R.id.btn_validate);

这是 onClick 代码 val_btn

String comp_name = mCompanyName.getText().toString().trim();

        HashMap<String, String> datamap = new HashMap<String, String>();
        datamap.put("Company Name", comp_name);

        mdatabase.push().setValue(datamap).addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                if (task.isSuccessful()) {
                    Toast.makeText(MainActivity.this, "updated  :)", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(MainActivity.this, "error  :(", Toast.LENGTH_SHORT).show();

                }
            }
        });

如果此代码在未使用Google Auth的情况下使用,则可以使用,但不适用于Google Auth.我已经正确设置了Firebase规则,我保证这不是问题.

if this code is used without google auth it works but it doesn't work with google auth. I have set up firebase rules correctly I assure that is not an issue.

错误是

E/RunLoop:Firebase数据库运行循环(3.0.0)中未捕获的异常.请报告至firebase-database-client@google.com java.lang.NoClassDefFoundError:无法解决以下问题:Lcom/google/firebase/FirebaseApp $ IdTokenListener;

E/RunLoop: Uncaught exception in Firebase Database runloop (3.0.0). Please report to firebase-database-client@google.com java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/FirebaseApp$IdTokenListener;

原因:java.lang.ClassNotFoundException:在路径:DexPathList [[zip文件"/data/app/com.mm.firebaselogin2-0Br4q5KgPHRacm8MT23I1w= =/base.apk],nativeLibraryDirectories = [/data/app/com.mm.firebaselogin2-0Br4q5KgPHRacm8MT23I1w ==/lib/arm64,/system/lib64]]

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.FirebaseApp$IdTokenListener" on path: DexPathList[[zip file "/data/app/com.mm.firebaselogin2-0Br4q5KgPHRacm8MT23I1w==/base.apk"],nativeLibraryDirectories=[/data/app/com.mm.firebaselogin2-0Br4q5KgPHRacm8MT23I1w==/lib/arm64, /system/lib64]]

推荐答案

请将Firebase数据库版本升级到17或最新的19.2.0:

Please upgrade your firebase database version to 17 or latest 19.2.0:

实现'com.google.firebase:firebase-database:17.0.0'

implementation 'com.google.firebase:firebase-database:17.0.0'

希望它会对您有所帮助.

Hope it will help you.

这篇关于成功通过Google身份验证后,使用实时数据库时应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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