【问题标题】:firestore crash runtimeException trying to get collectionfirestore crash runtimeException 试图获取集合
【发布时间】:2018-07-22 18:24:52
【问题描述】:

我正在尝试从 firestore 获取集合。我收到以下错误。

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

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

【问题讨论】:

    标签: android firebase google-cloud-firestore


    【解决方案1】:

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

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

    【讨论】:

    • 尝试将-keep class io.grpc.** {*;} 添加到您的proguard 配置中。它应该工作。就我而言,它奏效了。如果没有,请添加您的build.gradle 文件。
    • 我重新安装了应用程序,它现在可以工作了。似乎只有在我尝试调试应用程序时才会发生这种情况
    • 我的回答对你有帮助吗?
    • 它仍然不起作用,但它只发生在调试模式下
    猜你喜欢
    • 2019-02-17
    • 2020-03-07
    • 2018-04-09
    • 2019-07-06
    • 2021-03-04
    • 2018-07-13
    • 2018-06-23
    • 2019-12-24
    • 2020-09-03
    相关资源
    最近更新 更多