Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlatformException(7, not initialized, null, null) #316

Closed
xinoxapps opened this issue May 10, 2021 · 7 comments
Closed

PlatformException(7, not initialized, null, null) #316

xinoxapps opened this issue May 10, 2021 · 7 comments

Comments

@xinoxapps
Copy link

Test the example on IOS results in the following error:

flutter: PlatformException(7, not initialized, null, null), #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:581:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18)

#2 RtcEngine.createWithConfig (package:agora_rtc_engine/src/rtc_engine.dart:145:5)

#3 _State._initEngine (package:flutter_app_rtc/advanced/live_streaming.dart:86:11)


version: 1.0.0+1

environment:
sdk: ">=2.7.0 <3.0.0"

dependencies:
flutter:
sdk: flutter

permission_handler: ^7.1.0
agora_rtc_engine: ^4.0.0-rc.3


Any help?

@plutoless
Copy link

it seems you are trying to call apis before sdk is properly initialized. have you tried using our quickstart example?

@Manishmg3994
Copy link

it seems you are trying to call apis before sdk is properly initialized. have you tried using our quickstart example?
YES I am and at at a very Such level which can't be explained So please provide me Source code which works fine or just tell me the source codes for a audio and a video call as first it show a black screen issue then starts error PlatformException(7, not initialized, null, null) agora engine exception and these exceptions are out of my mind so please refer me a better documentation for just a simple audio and video call source code

@LichKing-2234
Copy link
Contributor

@Manishmg3994
Copy link

Manishmg3994 commented Jan 27, 2022 via email

@plutoless
Copy link

@Manishmg3994
you can find all types of token gen language samples here
https://github.com/AgoraIO/Tools/tree/master/DynamicKey/AgoraDynamicKey
migrating these to any cloud functions should be easy.

@ve-tarun
Copy link

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(7, not initialized, null, null)
E/flutter (10269): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter (10269): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter (10269):
E/flutter (10269): #2 RtcEngine.createWithContext (package:agora_rtc_engine/src/rtc_engine.dart:161:5)
E/flutter (10269):
E/flutter (10269): #3 _CallingState._initAgoraRtcEngine (package:chat/Screens/call.dart:62:15)
E/flutter (10269):
E/flutter (10269): #4 _CallingState.initialize (package:chat/Screens/call.dart:52:5)
haviing the same issue please hep
E/flutter (10269):
class Calling extends StatefulWidget {

const Calling({
Key? key,
}) : super(key: key);

@OverRide
_CallingState createState() => _CallingState();
}

class _CallingState extends State {
static final _users = [];
final _infoStrings = [];
bool muted = false;
late RtcEngine _engine;

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

@OverRide
void initState() {
super.initState();
// initialize agora sdk
initialize();
}

Future initialize() async {
await _initAgoraRtcEngine();
_addAgoraEventHandlers();
await _engine.enableAudioVolumeIndication(200, 3, true);
await _engine.joinChannel(token, "tarun", null, 0);
await _engine.enableDualStreamMode(true);

}

/// Create agora sdk instance and initialize
Future _initAgoraRtcEngine() async {
_engine = await RtcEngine.create(appId);
//await _engine.disableVideo();
await _engine.enableAudio();
await _engine.enableVideo();
}

/// Add agora event handlers
void _addAgoraEventHandlers() {
_engine.setEventHandler(RtcEngineEventHandler(
activeSpeaker: (uid) {
final String info = "Active speaker: $uid";
print(info);
},
error: (code) {
setState(() {
final info = 'onError: $code';
_infoStrings.add(info);
});
},
joinChannelSuccess: (channel, uid, elapsed) {
setState(() {
final info = 'onJoinChannel: $channel, uid: $uid';
_infoStrings.add(info);
});
},
leaveChannel: (stats) {
setState(() {
_infoStrings.add('onLeaveChannel');
_users.clear();
});
},
userJoined: (uid, elapsed) {
setState(() {
final info = 'userJoined: $uid';
_infoStrings.add(info);
_users.add(uid);
});
if (_users.length >= 5) {
print("Fallback to Low quality video stream");
_engine.setRemoteDefaultVideoStreamType(VideoStreamType.Low);
}
},
userOffline: (uid, reason) {
setState(() {
final info = 'userOffline: $uid , reason: $reason';
_infoStrings.add(info);
_users.remove(uid);
});
if (_users.length <= 3) {
print("Go back to High quality video stream");
_engine.setRemoteDefaultVideoStreamType(VideoStreamType.High);
}
},
));
}

/// Toolbar layout
Widget _toolbar() {
return Container(
alignment: Alignment.bottomCenter,
padding: const EdgeInsets.symmetric(vertical: 48),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
RawMaterialButton(
onPressed: _onToggleMute,
child: Icon(
muted ? Icons.mic_off : Icons.mic,
color: muted ? Colors.white : Colors.blueAccent,
size: 20.0,
),
shape: CircleBorder(),
elevation: 2.0,
fillColor: muted ? Colors.blueAccent : Colors.white,
padding: const EdgeInsets.all(12.0),
),
RawMaterialButton(
onPressed: () => _onCallEnd(context),
child: Icon(
Icons.call_end,
color: Colors.white,
size: 35.0,
),
shape: CircleBorder(),
elevation: 2.0,
fillColor: Colors.redAccent,
padding: const EdgeInsets.all(15.0),
),
RawMaterialButton(
onPressed: _onSwitchCamera,
child: Icon(
Icons.switch_camera,
color: Colors.blueAccent,
size: 20.0,
),
shape: CircleBorder(),
elevation: 2.0,
fillColor: Colors.white,
padding: const EdgeInsets.all(12.0),
)
],
),
);
}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Agora Group Video Calling'),
),
backgroundColor: Colors.black,
body: Center(
child: Stack(
children: [
_viewRows(),
_toolbar(),
],
),
),
);
}

/// Helper function to get list of native views
List _getRenderViews() {
final List list = [];
list.add(rtc_local_view.SurfaceView());
_users.forEach(
(int uid) => list.add(
rtc_remote_view.SurfaceView(
uid: uid,
),
),
);
return list;
}

/// Video view wrapper
Widget _videoView(view) {
return Expanded(child: Container(child: view));
}

/// Video view row wrapper
Widget _expandedVideoRow(List views) {
final wrappedViews = views.map(_videoView).toList();
return Expanded(
child: Row(
children: wrappedViews,
),
);
}

/// Video layout wrapper
Widget _viewRows() {
final views = _getRenderViews();
if (views.length == 1) {
return Container(
child: Column(
children: [_videoView(views[0])],
),
);
} else if (views.length == 2) {
return Container(
child: Column(
children: [
_expandedVideoRow([views[0]]),
_expandedVideoRow([views[1]])
],
));
} else if (views.length > 2 && views.length % 2 == 0) {
return Container(
child: Column(
children: [
for (int i = 0; i < views.length; i = i + 2)
_expandedVideoRow(
views.sublist(i, i + 2),
),
],
),
);
} else if (views.length > 2 && views.length % 2 != 0) {
return Container(
child: Column(
children: [
for (int i = 0; i < views.length; i = i + 2)
i == (views.length - 1)
? _expandedVideoRow(views.sublist(i, i + 1))
: _expandedVideoRow(views.sublist(i, i + 2)),
],
),
);
}
return Container();
}

void _onCallEnd(BuildContext context) {
Navigator.pop(context);
}

void _onToggleMute() {
setState(() {
muted = !muted;
});
_engine.muteLocalAudioStream(muted);
}

void _onSwitchCamera() {
_engine.switchCamera();
}
}

@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants