【问题标题】:Flutter Agora PlatformException(7, not initialized, null, null)Flutter Agora PlatformException(7, 未初始化, null, null)
【发布时间】:2021-12-16 11:03:56
【问题描述】:

我正在使用 Flutter Agora SDK 开发语音通话应用程序。到目前为止,我已经能够舒适地进行语音通话而没有任何错误。但是今天,在我的真实设备上测试它时,即使我没有对初始化过程进行任何更改,它也会出错。奇怪的是,它在模拟器上没有任何错误,但只有在真实设备上才会出错。

Future<void> initAgora() async {
    await [Permission.microphone].request();
    try {
      engine = await RtcEngine.createWithContext(RtcEngineContext(APP_ID));

      await engine.enableAudio();
      await engine.setChannelProfile(ChannelProfile.Communication);

      engine.setEventHandler(
        RtcEngineEventHandler(
          activeSpeaker: (i) {
            log("Active Speaker: $i");
          },
          microphoneEnabled: (enable) {
            log("Microphone: " + enable.toString());
            callingController.microphoneState.value = enable;
          },
          warning: (warningCode) {
            print(warningCode.toString());
          },
          rtcStats: (stats) {
            log("User Count: ${stats.userCount}");
          },
          connectionStateChanged: (state, reason) {
            log("Connection Changed : ${state.toString()}, ${reason.toString()}");
          },
          joinChannelSuccess: (String channel, int uid, int elapsed) {
            log('joinChannelSuccess $channel $uid');
          },
          userJoined: (int uid, int elapsed) {
            log('userJoined $uid');
          },
          userOffline: (int uid, UserOfflineReason reason) {
            log('userOffline $uid');
            callingController.finishCall(uid, "user_left");
          },
          error: (error) {
            log("ERROR: $error", name: "AGORA");
          },
        ),
      );

      if (callingController.isCallerMe) {
        await joinChannel();
      }
    } catch (e) {
      print(e);
      failureSnackbar(e.toString());
    }
  }

【问题讨论】:

  • 您使用的是什么真实设备?什么时候抛出这个异常?
  • 我的真机是小米9T Pro。 await engine.setChannelProfile() 工作时抛出的线。

标签: flutter agora.io


【解决方案1】:

您分享的错误是在 SDK 未正确初始化之前尝试调用方法时发生的。你能检查一下你的 RtcEngine 配置吗?此外,如果您在项目中启用了令牌,请确保将其传递给配置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-29
    • 2022-01-16
    • 2022-08-12
    • 1970-01-01
    • 1970-01-01
    • 2022-11-02
    • 2019-10-04
    • 2019-06-30
    相关资源
    最近更新 更多