我最近拿起了一个项目,我之前正在做一个项目,更新了依赖项,与这个事件相关,我将firestore的依赖项(com.google.firebase:firebase-firestore
)从17.1.5更新到了最新的18.2.0。
java.lang.IllegalStateException: FragmentManager已在执行事务
具体代码如下:
docRef.collection(COLLECTION_PATH).addSnapshotListener(Objects.requireNonNull(getActivity()), (queryDocumentSnapshots, e) -> {
//other stuff to do after detecting collection change
});
我猜Firestore中的某种行为改变破坏了我的代码,但我仍然不确定它到底是什么,以及如何修复它。
下面是详细的错误堆栈跟踪:
java.lang.IllegalStateException: FragmentManager is already executing transactions
at androidx.fragment.app.FragmentManagerImpl.ensureExecReady(FragmentManagerImpl.java:1657)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1717)
at androidx.fragment.app.FragmentManagerImpl.executePendingTransactions(FragmentManagerImpl.java:228)
at com.google.firebase.firestore.util.ListenerRegistrationImpl.lambda$onFragmentActivityStopCallOnce$1(com.google.firebase:firebase-firestore@@18.2.0:190)
at com.google.firebase.firestore.util.ListenerRegistrationImpl$$Lambda$2.run(Unknown Source:4)
at android.app.Activity.runOnUiThread(Activity.java:6282)
at com.google.firebase.firestore.util.ListenerRegistrationImpl.onFragmentActivityStopCallOnce(com.google.firebase:firebase-firestore@@18.2.0:174)
at com.google.firebase.firestore.util.ListenerRegistrationImpl.<init>(com.google.firebase:firebase-firestore@@18.2.0:209)
at com.google.firebase.firestore.Query.addSnapshotListenerInternal(com.google.firebase:firebase-firestore@@18.2.0:917)
at com.google.firebase.firestore.Query.addSnapshotListener(com.google.firebase:firebase-firestore@@18.2.0:882)
at com.google.firebase.firestore.Query.addSnapshotListener(com.google.firebase:firebase-firestore@@18.2.0:823)
... [My app's call to addSnapshotListener] ...
at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2565)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:907)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1235)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1301)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:710)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2071)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1861)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1816)
at androidx.fragment.app.FragmentManagerImpl.execSingleAction(FragmentManagerImpl.java:1693)
at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:560)
at androidx.fragment.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:148)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1244)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092)
at androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java:1622)
at android.view.View.measure(View.java:23169)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749)
at androidx.coordinatorlayout.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:743)
at androidx.coordinatorlayout.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:815)
at android.view.View.measure(View.java:23169)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
at android.view.View.measure(View.java:23169)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749)
at androidx.appcompat.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:403)
at android.view.View.measure(View.java:23169)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:23169)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749)
https://stackoverflow.com/questions/55608927
复制相似问题