10000 Unable to getUserMedia: Attempt to invoke virtual method 'android.content.Intent android.app.Activity.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)' on a null object reference · Issue #1799 · flutter-webrtc/flutter-webrtc · GitHub
[go: up one dir, main page]

Skip to content

Unable to getUserMedia: Attempt to invoke virtual method 'android.content.Intent android.app.Activity.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)' on a null object reference #1799

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

Open
devKaran-coder opened this issue Mar 25, 2025 · 2 comments

Comments

@devKaran-coder
Copy link

I am using flutter_webrtc plugin from sip_ua with flutter_foreground_task in between when I call this function which is mention below I got this error

  • Flutter version: 3.29.0
  • Plugin version: flutter_webrtc-0.12.12+hotfix.1
  • OS: Android

_funcForCalling(String number) async {
try {
final mediaConstraints = <String, dynamic>{'audio': true, 'video': false};

webrtc.MediaStream mediaStream;

mediaConstraints['video'] = false;
mediaStream =
    await webrtc.navigator.mediaDevices.getUserMedia(mediaConstraints);

helper!.call(number, mediaStream: mediaStream);

} catch (e, s) {
print("error is $e");
print("stack stace is $s");
}
}

E/MethodChannel#FlutterWebRTC.Method(31010): Failed to handle method call
E/MethodChannel#FlutterWebRTC.Method(31010): java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Intent android.app.Activity.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)' on a null object reference
E/MethodChannel#FlutterWebRTC.Method(31010): at com.cloudwebrtc.webrtc.video.camera.DeviceOrientationManager.start(DeviceOrientationManager.java:57)
E/MethodChannel#FlutterWebRTC.Method(31010): at com.cloudwebrtc.webrtc.video.camera.CameraUtils.(CameraUtils.java:48)
E/MethodChannel#FlutterWebRTC.Method(31010): at com.cloudwebrtc.webrtc.MethodCallHandlerImpl.initialize(MethodCallHandlerImpl.java:176)
E/MethodChannel#FlutterWebRTC.Method(31010): at com.cloudwebrtc.webrtc.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:345)
E/MethodChannel#FlutterWebRTC.Method(31010): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/MethodChannel#FlutterWebRTC.Method(31010): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/MethodChannel#FlutterWebRTC.Method(31010): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#FlutterWebRTC.Method(31010): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
E/MethodChannel#FlutterWebRTC.Method(31010): at android.os.Handler.handleCallback(Handler.java:959)
E/MethodChannel#FlutterWebRTC.Method(31010): at android.os.Handler.dispatchMessage(Handler.java:100)
E/MethodChannel#FlutterWebRTC.Method(31010): at android.os.Looper.loopOnce(Looper.java:232)
E/MethodChannel#FlutterWebRTC.Method(31010): at android.os.Looper.loop(Looper.java:317)
E/MethodChannel#FlutterWebRTC.Method(31010): at android.app.ActivityThread.main(ActivityThread.java:8705)
E/MethodChannel#FlutterWebRTC.Method(31010): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#FlutterWebRTC.Method(31010): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
E/MethodChannel#FlutterWebRTC.Method(31010): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
I/flutter (31010): error is Unable to getUserMedia: Attempt to invoke virtual method 'android.content.Intent android.app.Activity.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)' on a null object reference
I/flutter (31010): stack stace is #0 MediaDeviceNative.getUserMedia (package:flutter_webrtc/src/native/mediadevices_impl.dart:48:7)
I/flutter (31010):
I/flutter (31010): #1 CallTaskHandler._handleOutGoingCall (package:adit.app/utils/forground_service/call_task_handler.dart:864:11)
I/flutter (31010):

@harryandroiddev
Copy link

same issue

@robsonvasquez
6EE8
Copy link

@devKaran-coder @harryandroiddev

I experienced this issue with getUserMedia only when trying to answer a call while the app was in the background.

Due to Apple’s requirement to update apps for iOS 18, I updated the libraries and noticed that WebRTC stopped working in the background on Android starting from version "12.0.0", resulting in the same error you're seeing.

If your app doesn’t have issues using an older WebRTC version on Android, I recommend using "0.10.8", which works.
You can also try up to version "0.11.7" — I haven’t tested that one myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0