尝试更新文档时,Firestore(0.6.6-dev)中出现内部错误 [英] Internal error in Firestore (0.6.6-dev) when trying to update document

查看:51
本文介绍了尝试更新文档时,Firestore(0.6.6-dev)中出现内部错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下错误使我很难受.我正在尝试更新存储在Firestore项目中的文档中的单个字段.

The following error is giving me a hard time. I'm trying to update a single field in a document stored in my Firestore project.

    E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
  at com.google.android.gms.internal.zzejs.run(Unknown Source)
  at android.os.Handler.handleCallback(Handler.java:725)
  at android.os.Handler.dispatchMessage(Handler.java:92)
  at android.os.Looper.loop(Looper.java:176)
  at android.app.ActivityThread.main(ActivityThread.java:5365)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
  at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Cannot perform this operation because there is no current transaction.
  at android.database.sqlite.SQLiteSession.throwIfNoTransaction(SQLiteSession.java:926)
  at android.database.sqlite.SQLiteSession.endTransaction(SQLiteSession.java:398)
  at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:524)
  at com.google.android.gms.internal.zzefi.zzb(Unknown Source)
  at com.google.android.gms.internal.zzedu.zzcao(Unknown Source)
  at com.google.android.gms.internal.zzedu.start(Unknown Source)
  at com.google.android.gms.internal.zzeca.zza(Unknown Source)
  at com.google.android.gms.internal.zzecc.run(Unknown Source)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:153)
  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
  at com.google.android.gms.internal.zzejp$zza.run(Unknown Source)
  at java.lang.Thread.run(Thread.java:856)

这是我的代码:

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();

if(user == null){
    Log.e(LOGTAG, "Could not upload because user is not logged in.");
    return;
}

FirebaseFirestore db = FirebaseFirestore.getInstance();
DocumentReference userRef = db.collection("users").document(user.getUid());

TextInputEditText textview = findViewById(R.id.edit_text_foo);
String enteredText = textview.getText().toString(); //implements CharSequence, thus toString() gives the correct string
userRef.update("field_foo", enteredText)
        .addOnSuccessListener(new OnSuccessListener<Void>() {
            @Override
            public void onSuccess(Void aVoid) {
                Log.i(LOGTAG, "Text successfully updated!");
            }
        })
        .addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Log.w(TAG, "Error updating text", e);
            }
        });

每次执行该方法时都会发生错误.恕我直言,内部错误"一词可能表明Firestore数据库的早期Beta状态确实确实存在问题.但是,这是我的第一个android应用程序,而且我也是Firebase的新手,因此欢迎任何合格的估值,任何解决方案的想法或任何指向愚蠢的newbe错误的指针.

The error occurs everytime the method is executed. Imho, the "internal error" phrase might indicate that this is indeed a problem coming with the early beta status of the Firestore database. However, this is my first android app and I'm also new to Firebase, so any qualified valuation, any idea for a solution or any pointer to a stupid newbe mistake is welcome.

预先感谢, DanD

Thanks in advance, DanD

推荐答案

感谢@hatboysam,现在可以使用了. 解决方案非常简单:

Thanks to @hatboysam, it works now. The solution is as simple as can be:

在设备上的应用程序管理器中清除数据.

然后再次运行该应用程序.

Then run the app again.

这篇关于尝试更新文档时,Firestore(0.6.6-dev)中出现内部错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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