AgoraIO-Extensions / Agora-Flutter-SDK

Flutter plugin of Agora RTC SDK for Android/iOS/macOS/Windows

Home Page:https://pub.dev/packages/agora_rtc_engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error ErrorCode.InvalidToken Flutter Agora

RanaSharjeelShji opened this issue · comments

Version of the agora_rtc_engine

5.3.0

Platforms affected

  • Android
  • iOS
  • macOS
  • Windows
  • Web

Steps to reproduce

Simply added the example of video call it worked fine for me.
When I try to generate build I got some errors and I update the kotlin version and compile sdk version now it's not working

Expected results

video call should run perfectly

Actual results

video is not showing up, no audio transmission

Code sample

// ignore_for_file: library_prefixes

import 'package:agora_rtc_engine/rtc_engine.dart';
import 'package:agora_rtc_engine/rtc_local_view.dart' as rtcLocalView;
import 'package:agora_rtc_engine/rtc_remote_view.dart' as rtcRemoteView;
import 'package:flutter/material.dart';

import 'credentials.dart';

class CallScreen extends StatefulWidget {
final String? channelName;
final ClientRole? role;

const CallScreen({Key? key, this.channelName, this.role}) : super(key: key);

@OverRide
State createState() => _CallScreenState();
}

class _CallScreenState extends State {
final _users = [];
final _infoStrings = [];
bool muted = false;
bool viewPanel = false;
late RtcEngine _engine;
@OverRide
void initState() {
super.initState();
initialize();
}

@OverRide
void dispose() {
_users.clear();
_engine.leaveChannel();
_engine.destroy();
super.dispose();
}

Future initialize() async {
if (appId.isEmpty) {
setState(() {
_infoStrings.add('App ID missing, please provide your APP ID ');
_infoStrings.add('Agora Engine is not starting');
});
return;
}
_engine = await RtcEngine.create(appId);
await _engine.enableVideo();
await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
await _engine.setClientRole(widget.role!);
_addAgoraEventHandler();
VideoEncoderConfiguration configuration = VideoEncoderConfiguration();
configuration.dimensions = const VideoDimensions(width: 1920, height: 1080);
await _engine.setVideoEncoderConfiguration(configuration);
await _engine.joinChannel(token, 'cha', null, 0);
}

void _addAgoraEventHandler() {
_engine.setEventHandler(RtcEngineEventHandler(
error: (code) {
setState(() {
final info = 'Error $code';
_infoStrings.add(info);
});
},
joinChannelSuccess: (channel, uid, elapsed) {
setState(() {
final info = 'Join Channel: $channel, uid: $uid';
_infoStrings.add(info);
});
},
leaveChannel: (stats) {
setState(() {
_infoStrings.add('Leave Channel');
_users.clear();
});
},
userJoined: (uid, elapsed) {
setState(() {
final info = 'User Joined: $uid';
_infoStrings.add(info);
_users.add(uid);
});
},
userOffline: (uid, elapsed) {
setState(() {
final info = 'User Offline: $uid';
_infoStrings.add(info);
_users.remove(uid);
});
},
firstRemoteVideoFrame: (uid, width, height, elapsed) {
setState(() {
final info = 'First Remote Video: $uid ${width}x$height';
_infoStrings.add(info);
});
},
));
}

Widget _viewRows() {
final List list = [];
if (widget.role == ClientRole.Broadcaster) {
list.add(const rtcLocalView.SurfaceView());
}
for (var uid in _users) {
list.add(rtcRemoteView.SurfaceView(
uid: uid,
channelId: widget.channelName!,
));
}
final views = list;
return Column(
children: List.generate(
views.length,
(index) => Expanded(
child: views[index],
),
),
);
}

Widget _toolbar() {
if (widget.role == ClientRole.Audience) {
return const SizedBox();
}
return Container(
alignment: Alignment.bottomCenter,
padding: const EdgeInsets.symmetric(vertical: 48),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
RawMaterialButton(
onPressed: () {
setState(() {
muted = !muted;
});
_engine.muteLocalAudioStream(muted);
},
shape: const CircleBorder(),
elevation: 2.0,
fillColor: muted ? Colors.blueAccent : Colors.white,
padding: const EdgeInsets.all(12.0),
child: Icon(
muted ? Icons.mic_off : Icons.mic,
color: muted ? Colors.white : Colors.blueAccent,
size: 20.0,
),
),
RawMaterialButton(
onPressed: () => Navigator.pop(context),
shape: const CircleBorder(),
elevation: 2.0,
fillColor: Colors.redAccent,
padding: const EdgeInsets.all(15.0),
child: const Icon(
Icons.call_end,
color: Colors.white,
size: 35.0,
),
),
RawMaterialButton(
onPressed: () {
_engine.switchCamera();
},
shape: const CircleBorder(),
elevation: 2.0,
fillColor: Colors.white,
padding: const EdgeInsets.all(12.0),
child: const Icon(
Icons.switch_camera,
color: Colors.blueAccent,
size: 20.0,
),
),
],
),
);
}

Widget _panel() {
return Visibility(
visible: viewPanel,
child: Container(
padding: const EdgeInsets.symmetric(vertical: 48),
alignment: Alignment.bottomCenter,
child: FractionallySizedBox(
heightFactor: 0.5,
child: Container(
padding: const EdgeInsets.symmetric(vertical: 48),
child: ListView.builder(
reverse: true,
itemCount: _infoStrings.length,
itemBuilder: (BuildContext context, int index) {
if (_infoStrings.isEmpty) {
return const Text("null");
}
return Padding(
padding: EdgeInsets.symmetric(vertical: 3, horizontal: 10),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: Container(
padding: const EdgeInsets.symmetric(
vertical: 2,
horizontal: 5,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(5),
),
child: Text(
_infoStrings[index],
style: const TextStyle(
color: Colors.blueGrey,
),
),
),
),
],
),
);
},
),
),
),
),
);
}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Agora'),
centerTitle: true,
actions: [
IconButton(
onPressed: () {
setState(() {
viewPanel = !viewPanel;
});
},
icon: const Icon(Icons.info_outline),
),
],
),
backgroundColor: Colors.black,
body: Center(
child: Stack(
children: [
_viewRows(),
_panel(),
_toolbar(),
],
),
),
);
}
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

D/spdlog (32020): [2024-03-26 15:01:12.157] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:104 CallApi api_type 0 params {"context":{"appId":"f7d73b94733b4ba1bee054045b3f4312"},"appGroup":null}
D/agora-jni(32020): android bridge create done...
W/libc (32020): Access denied finding property "net.dns1"
W/libc (32020): Access denied finding property "net.dns2"
W/libc (32020): Access denied finding property "net.dns3"
W/libc (32020): Access denied finding property "net.dns4"
D/spdlog (32020): [2024-03-26 15:01:12.253] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/android/iris_rtc_engine_impl_android.cc:243 CallApi Android RtcEngine handle -5476376604532779776
D/spdlog (32020): [2024-03-26 15:01:12.253] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:114 CallApi ret 0 result
D/spdlog (32020): [2024-03-26 15:01:12.256] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:104 CallApi api_type 132 params {"code":1}
D/spdlog (32020): [2024-03-26 15:01:12.256] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:114 CallApi ret 0 result general failure
W/ (32020): general failure
D/spdlog (32020): [2024-03-26 15:01:12.256] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:104 CallApi api_type 132 params {"code":1}
D/spdlog (32020): [2024-03-26 15:01:12.256] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:114 CallApi ret 0 result general failure
W/ (32020): general failure
D/spdlog (32020): [2024-03-26 15:01:12.257] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:129 CallApi api_type 20 params {"canvas":{"uid":0,"channelId":null,"renderMode":1,"mirrorMode":0}}
D/spdlog (32020): [2024-03-26 15:01:12.258] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:139 CallApi ret 0 result
I/PlatformViewsController(32020): Hosting view in view hierarchy for platform view: 9
D/BufferQueueConsumer(32020): connect: controlledByApp=true
D/Surface (32020): lockHardwareCanvas
W/libc (32020): Access denied finding property "ro.vendor.display.iris_x7.support"
D/OpenGLRenderer(32020): makeCurrent grContext:0xb400007e46b39f80 reset mTextureAvailable
E/FrameEvents(32020): updateAcquireFence: Did not find frame.
W/libc (32020): Access denied finding property "net.dns1"
W/libc (32020): Access denied finding property "net.dns2"
W/libc (32020): Access denied finding property "net.dns3"
W/libc (32020): Access denied finding property "net.dns4"
D/spdlog (32020): [2024-03-26 15:01:12.270] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:104 CallApi api_type 162 params {"appType":4}
D/spdlog (32020): [2024-03-26 15:01:12.270] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:114 CallApi ret 0 result
D/spdlog (32020): [2024-03-26 15:01:12.271] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:104 CallApi api_type 15 params {}
D/CameraInjector(32020): updateCloudCameraControllerInfoAsync: has aleardy start update task.
D/CameraInjector(32020): waitForResult:
D/spdlog (32020): [2024-03-26 15:01:12.277] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:114 CallApi ret 0 result
D/Surface (32020): lockHardwareCanvas
D/TextureView(32020): getHardwareLayer, createNewSurface:true
D/BufferQueueConsumer(32020): connect: controlledByApp=true
D/libMEOW (32020): meow new tls: 0xb400007db344c900
D/libMEOW (32020): applied 1 plugins for [com.example.flutter_application_1]:
D/libMEOW (32020): plugin 1: [libMEOW_gift.so]: 0xb400007e4c703b00
D/libMEOW (32020): rebuild call chain: 0xb400007db36e1a80
E/FrameEvents(32020): updateAcquireFence: Did not find frame.
D/spdlog (32020): [2024-03-26 15:01:12.292] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:104 CallApi api_type 2 params {"profile":1}
D/spdlog (32020): [2024-03-26 15:01:12.292] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:114 CallApi ret 0 result
D/Surface (32020): lockHardwareCanvas
D/BufferQueueConsumer(32020): connect: controlledByApp=true
I/AGORA_SDK(32020): Surface changed to width 1080 height 2019
E/FrameEvents(32020): updateAcquireFence: Did not find frame.
D/spdlog (32020): [2024-03-26 15:01:12.304] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:104 CallApi api_type 3 params {"role":1,"options":null}
D/spdlog (32020): [2024-03-26 15:01:12.305] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:114 CallApi ret 0 result
D/spdlog (32020): [2024-03-26 15:01:12.309] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:104 CallApi api_type 18 params {"config":{"dimensions":{"width":1920,"height":1080}}}
D/spdlog (32020): [2024-03-26 15:01:12.309] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:114 CallApi ret 0 result
D/Surface (32020): lockHardwareCanvas
E/FrameEvents(32020): updateAcquireFence: Did not find frame.
D/spdlog (32020): [2024-03-26 15:01:12.316] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:104 CallApi api_type 4 params {"token":"007eJxTYNhcGrt/UkEE01vFZ3tmSl27M7V2l3OR0s8pNuKsBruDr91RYEgzTzE3TrI0MTc2TjJJSjRMSk01MDUxMDFNMk4zMTY0sprNlNYQyMiwSnEWMyMDBIL4LAzFGVmZDAwAYX4e8Q==","channelId":"cha","info":null,"uid":0,"options":null}
W/libc (32020): Access denied finding property "net.dns1"
W/libc (32020): Access denied finding property "net.dns2"
W/libc (32020): Access denied finding property "net.dns3"
W/libc (32020): Access denied finding property "net.dns4"
D/spdlog (32020): [2024-03-26 15:01:12.514] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:114 CallApi ret 0 result
D/libMEOW (32020): meow new tls: 0xb400007d73667a40
D/libMEOW (32020): applied 1 plugins for [com.example.flutter_application_1]:
D/libMEOW (32020): plugin 1: [libMEOW_gift.so]: 0xb400007e4c703b00
D/libMEOW (32020): rebuild call chain: 0xb400007d7369dc40
D/GDPGlUtil(32020): EGLContext created, client version 3
D/WEBRTCN(32020): SetRenderAndroidVM
D/CameraInjector(32020): updateCloudCameraControllerInfoAsync: has aleardy start update task.
D/CameraInjector(32020): waitForResult:
I/GDPAndroid(32020): cores:8
I/GDPAndroid(32020): cores:8
I/GDPAndroid(32020): cores:8
I/GDPAndroid(32020): cores:8
I/GDPAndroid(32020): cores:8
I/GDPAndroid(32020): cores:8
I/GDPAndroid(32020): cores:8
I/GDPAndroid(32020): cores:8
I/GDPAndroid(32020): cores:8
I/GDPAndroid(32020): cores:8
I/GDPAndroid(32020): max freq:3000000
I/GDPAndroid(32020): total mem:7866048512
E/spdlog (32020): [2024-03-26 15:01:12.738] [0] [error] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/internal/rtc_engine_event_handler.cc:56 onError err 110 msg nullptr
E/spdlog (32020): [2024-03-26 15:01:12.827] [0] [error] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/internal/rtc_engine_event_handler.cc:56 onError err 110 msg nullptr
E/spdlog (32020): [2024-03-26 15:01:12.890] [0] [error] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/internal/rtc_engine_event_handler.cc:56 onError err 110 msg nullptr
W/GENP.0 (32020): type=1400 audit(0.0:188390): avc: denied { search } for name="thermal" dev="sysfs" ino=28549 scontext=u:r:untrusted_app_32:s0:c246,c257,c512,c768 tcontext=u:object_r:sysfs_therm:s0 tclass=dir permissive=0 app=com.example.flutter_application_1
W/GENP.0 (32020): type=1400 audit(0.0:188391): avc: denied { search } for name="thermal" dev="sysfs" ino=28549 scontext=u:r:untrusted_app_32:s0:c246,c257,c512,c768 tcontext=u:object_r:sysfs_therm:s0 tclass=dir permissive=0 app=com.example.flutter_application_1
W/GENP.0 (32020): type=1400 audit(0.0:188392): avc: denied { search } for name="thermal" dev="sysfs" ino=28549 scontext=u:r:untrusted_app_32:s0:c246,c257,c512,c768 tcontext=u:object_r:sysfs_therm:s0 tclass=dir permissive=0 app=com.example.flutter_application_1
W/GENP.0 (32020): type=1400 audit(0.0:188393): avc: denied { search } for name="thermal" dev="sysfs" ino=28549 scontext=u:r:untrusted_app_32:s0:c246,c257,c512,c768 tcontext=u:object_r:sysfs_therm:s0 tclass=dir permissive=0 app=com.example.flutter_application_1
W/GENP.0 (32020): type=1400 audit(0.0:188394): avc: denied { search } for name="thermal" dev="sysfs" ino=28549 scontext=u:r:untrusted_app_32:s0:c246,c257,c512,c768 tcontext=u:object_r:sysfs_therm:s0 tclass=dir permissive=0 app=com.example.flutter_application_1
W/libc (32020): Access denied finding property "net.dns1"
W/libc (32020): Access denied finding property "net.dns2"
W/libc (32020): Access denied finding property "net.dns3"
W/libc (32020): Access denied finding property "net.dns4"
W/GENP.0 (32020): type=1400 audit(0.0:188396): avc: denied { search } for name="thermal" dev="sysfs" ino=28549 scontext=u:r:untrusted_app_32:s0:c246,c257,c512,c768 tcontext=u:object_r:sysfs_therm:s0 tclass=dir permissive=0 app=com.example.flutter_application_1
W/GENP.0 (32020): type=1400 audit(0.0:188397): avc: denied { search } for name="thermal" dev="sysfs" ino=28549 scontext=u:r:untrusted_app_32:s0:c246,c257,c512,c768 tcontext=u:object_r:sysfs_therm:s0 tclass=dir permissive=0 app=com.example.flutter_application_1
W/GENP.0 (32020): type=1400 audit(0.0:188398): avc: denied { search } for name="thermal" dev="sysfs" ino=28549 scontext=u:r:untrusted_app_32:s0:c246,c257,c512,c768 tcontext=u:object_r:sysfs_therm:s0 tclass=dir permissive=0 app=com.example.flutter_application_1
W/GENP.0 (32020): type=1400 audit(0.0:188399): avc: denied { search } for name="thermal" dev="sysfs" ino=28549 scontext=u:r:untrusted_app_32:s0:c246,c257,c512,c768 tcontext=u:object_r:sysfs_therm:s0 tclass=dir permissive=0 app=com.example.flutter_application_1
W/GENP.0 (32020): type=1400 audit(0.0:188400): avc: denied { search } for name="thermal" dev="sysfs" ino=28549 scontext=u:r:untrusted_app_32:s0:c246,c257,c512,c768 tcontext=u:object_r:sysfs_therm:s0 tclass=dir permissive=0 app=com.example.flutter_application_1
D/libMEOW (32020): meow delete tls: 0xb400007db344c900
D/BufferQueueConsumer(32020): SurfaceTexture-0-32020-35 disconnect
D/spdlog (32020): [2024-03-26 15:01:17.535] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:104 CallApi api_type 6 params {}
D/spdlog (32020): [2024-03-26 15:01:17.543] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:114 CallApi ret 0 result
D/spdlog (32020): [2024-03-26 15:01:17.552] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:104 CallApi api_type 1 params {"sync":true}
I/spdlog (32020): [2024-03-26 15:01:17.633] [0] [info] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/internal/rtc_engine_event_handler.cc:98 onLeaveChannel
D/WEBRTCN(32020): SetRenderAndroidVM
D/agora-jni(32020): android bridge destroy done...
D/spdlog (32020): [2024-03-26 15:01:17.692] [0] [debug] /tmp/jenkins/IRIS-SDK/rtc/cxx/src/iris_rtc_engine.cc:114 CallApi ret 0 result
D/libMEOW (32020): meow delete tls: 0xb400007d73667a40

Flutter Doctor output

Doctor output
 flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.16.9, on Microsoft Windows [Version 10.0.19045.4170], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2022.3)
[√] VS Code (version 1.87.2)
[√] Connected device (4 available)
[√] Network resources

I think you should make sure the token is valid.

I think you should make sure the token is valid.

I've verified that, the token is valid. more over I've generated the new token after that I printed that token before Agora engine starts it is a valid token. I've double checked that

Can you try the example on the main branch?

I got the root issue. The channel was not created in the first attempt. create channel it will show black screen without hangup the call hot restart the app re-join channel it will work. but after that I was not able list audio of other user and I was mute for other user. Now I'm just using flutter Ui Kit package it is working good.

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. If you find this problem please file a new issue with the same description, what happens, logs and the output. All system setups can be slightly different so it's always better to open new issues and reference the related ones. Thanks for your contribution.

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please raise a new issue.