【问题标题】:Flutter: Firestore Transaction Crashes Android emulationFlutter:Firestore 事务崩溃 Android 仿真
【发布时间】:2020-02-27 06:48:20
【问题描述】:

我正在尝试使用 Firestore 运行一个事务,该事务将增加一个投票计数器。 我正在运行以下代码:

Firestore.instance.runTransaction((Transaction tx) async {
          DocumentSnapshot postSnapshot = await tx.get(postRef);
          if (postSnapshot.exists) {
            //print(postSnapshot.data['Votes']);
            await tx.update(postRef, <String, dynamic>{'Votes': postSnapshot.data['Votes'] + 1})
          .catchError((e) {print(e);});
          }
        }).catchError((e) {
          print(e);
        });

有时,这可以正常工作,但有时它会导致我的 android 模拟器静默崩溃 - 应用程序关闭并且控制台显示 Lost connection to devicecatchError 语句都不会打印,并且控制台没有输出。颤振医生报告没有问题。这在 iOS 上似乎不是问题,尽管由于错误是零星的,所以很难说。 我的 Flutter 版本是 Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-US)

有谁知道为什么会发生这种情况?这是颤振的问题还是我运行事务的方式有问题?任何帮助将不胜感激,谢谢!

【问题讨论】:

    标签: android flutter dart google-cloud-firestore transactions


    【解决方案1】:

    这可能很难。您没有提及 Android Studio 的版本以及您运行的 android 设备和操作系统版本。我建议尝试安装另一个虚拟设备并检查。在这里你有很好的tutorial for Mac。

    如果这不起作用,则有一个troubleshooting emulator 页面,如果您在那里没有发现问题,您可以报告错误。

    祝你好运!

    【讨论】:

    • 我正在使用 Android Studio 3.5,我正在使用 android 9.0 和 API 28 在 Pixel 2 上进行仿真。
    猜你喜欢
    • 2020-06-22
    • 1970-01-01
    • 2015-05-06
    • 1970-01-01
    • 2020-04-23
    • 2019-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多