Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
799 views
in Technique[技术] by (71.8m points)

android - Internal error in Firestore (0.6.6-dev) when trying to update document

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)

Here is my code:

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);
            }
        });

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.

Thanks in advance, DanD

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...