本文介绍了firestore崩溃runtimeException试图获取集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Firestore获取集合.我遇到了以下错误.

I am trying to get collection from firestore .I am getting the following error .

java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
        at com.google.firebase.firestore.g.zza.zzb(SourceFile:324)
        at com.google.firebase.firestore.g.zzd.run(Unknown Source)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:145)
        at android.app.ActivityThread.main(ActivityThread.java:5834)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
     Caused by: java.lang.AssertionError: INTERNAL ASSERTION FAILED: Only one thread may be created in an AsyncQueue.
        at com.google.a.a.a.a.zza.zza(SourceFile:2032)
        at com.google.a.a.a.a.zza.zza(SourceFile:2017)
        at com.google.firebase.firestore.g.zza$zza.newThread(SourceFile:195)
        at java.util.concurrent.ThreadPoolExecutor$Worker.<init>(ThreadPoolExecutor.java:582)
        at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:988)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at com.google.firebase.firestore.g.zza$zza.run(SourceFile:191)
        at java.lang.Thread.run(Thread.java:820)

和代码

private FirebaseAuth mAuth;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        mAuth = FirebaseAuth.getInstance();


        mAuth.signInWithEmailAndPassword("username","password").addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
            @Override
            public void onComplete(@NonNull Task<AuthResult> task) {

                FirebaseFirestore db = FirebaseFirestore.getInstance();
                db.collection("mycollection").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
                    @Override
                    public void onComplete(@NonNull Task<QuerySnapshot> task) {

                    }
                }).addOnFailureListener(new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception e) {

                    }
                });

            }
        });

firebase身份验证工作正常,但当我尝试如下所示收集集合时,代码崩溃.有时代码工作正常,并且onComplete被称为

the firebase authentication is working fine but the code is crashing when i try to get the collection as shown below .Sometimes the code works fine and onComplete is called

db.collection("mycollection").get().addOnCompleteListener

推荐答案

首先,尝试清除设备上应用程序管理器中的数据,然后再次运行该应用程序.如果它不能以这种方式工作,请尝试将以下代码行添加到progauard规则中:

First, try to clear the data in the application manager on the device and run the app again. If it's not working in this way, try add the following lines of code to progauard rule:

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

这篇关于firestore崩溃runtimeException试图获取集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 12:55