better_player stop working after add video_trimmer in flutter - flutter

Better_Player worked before adding Video_Trimmer, but after I added Video_Trimmer, it stopped playing the video, and if I remove Video_Trimmer again, Better_Player works.
Things I tested:
Uninstalling and reinstalling the application
Using lower versions of Better_Player
better_player: ^0.0.83
video_trimmer: ^1.1.3
console error is:
E/MethodChannel#better_player_channel(18557): Failed to handle method call
E/MethodChannel#better_player_channel(18557): java.lang.NullPointerException: MediaSource.Factory#setDrmSessionManagerProvider no longer handles null by instantiating a new DefaultDrmSessionManagerProvider. Explicitly construct and pass an instance in order to retain the old behavior.
E/MethodChannel#better_player_channel(18557): at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:174)
E/MethodChannel#better_player_channel(18557): at com.google.android.exoplayer2.source.ProgressiveMediaSource$Factory.setDrmSessionManagerProvider(ProgressiveMediaSource.java:186)
E/MethodChannel#better_player_channel(18557): at com.jhomlala.better_player.BetterPlayer.buildMediaSource(BetterPlayer.kt:430)
E/MethodChannel#better_player_channel(18557): at com.jhomlala.better_player.BetterPlayer.setDataSource(BetterPlayer.kt:196)
E/MethodChannel#better_player_channel(18557): at com.jhomlala.better_player.BetterPlayerPlugin.setDataSource(BetterPlayerPlugin.kt:277)
E/MethodChannel#better_player_channel(18557): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:151)
E/MethodChannel#better_player_channel(18557): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:138)
E/MethodChannel#better_player_channel(18557): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#better_player_channel(18557): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/MethodChannel#better_player_channel(18557): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#better_player_channel(18557): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#better_player_channel(18557): at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#better_player_channel(18557): at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#better_player_channel(18557): at android.os.Looper.loopOnce(Looper.java:210)
E/MethodChannel#better_player_channel(18557): at android.os.Looper.loop(Looper.java:299)
E/MethodChannel#better_player_channel(18557): at android.app.ActivityThread.main(ActivityThread.java:8273)
E/MethodChannel#better_player_channel(18557): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#better_player_channel(18557): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
E/MethodChannel#better_player_channel(18557): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1073)
E/flutter (18557): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(error, MediaSource.Factory#setDrmSessionManagerProvider no longer handles null by instantiating a new DefaultDrmSessionManagerProvider. Explicitly construct and pass an instance in order to retain the old behavior., null, java.lang.NullPointerException: MediaSource.Factory#setDrmSessionManagerProvider no longer handles null by instantiating a new DefaultDrmSessionManagerProvider. Explicitly construct and pass an instance in order to retain the old behavior.
E/flutter (18557): at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:174)
E/flutter (18557): at com.google.android.exoplayer2.source.ProgressiveMediaSource$Factory.setDrmSessionManagerProvider(ProgressiveMediaSource.java:186)
E/flutter (18557): at com.jhomlala.better_player.BetterPlayer.buildMediaSource(BetterPlayer.kt:430)
E/flutter (18557): at com.jhomlala.better_player.BetterPlayer.setDataSource(BetterPlayer.kt:196)
E/flutter (18557): at com.jhomlala.better_player.BetterPlayerPlugin.setDataSource(BetterPlayerPlugin.kt:277)
E/flutter (18557): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:151)
E/flutter (18557): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:138)
E/flutter (18557): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/flutter (18557): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/flutter (18557): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/flutter (18557): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/flutter (18557): at android.os.Handler.handleCallback(Handler.java:938)
E/flutter (18557): at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter (18557): at android.os.Looper.loopOnce(Looper.java:210)
E/flutter (18557): at android.os.Looper.loop(Looper.java:299)
E/flutter (18557): at android.app.ActivityThread.main(ActivityThread.java:8273)
E/flutter (18557): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (18557): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
E/flutter (18557): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1073)
E/flutter (18557): )
E/flutter (18557): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter (18557): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter (18557): <asynchronous suspension>
E/flutter (18557): #2 MethodChannelVideoPlayer.setDataSource (package:better_player/src/video_player/method_channel_video_player.dart:118:5)
E/flutter (18557): <asynchronous suspension>
E/flutter (18557): #3 VideoPlayerController._setDataSource (package:better_player/src/video_player/video_player.dart:408:5)
E/flutter (18557): <asynchronous suspension>
E/flutter (18557): #4 BetterPlayerController._setupDataSource (package:better_player/src/core/better_player_controller.dart:485:9)
E/flutter (18557): <asynchronous suspension>
E/flutter (18557): #5 BetterPlayerController.setupDataSource (package:better_player/src/core/better_player_controller.dart:274:5)
E/flutter (18557): <asynchronous suspension>
E/flutter (18557):
W/System (18557): A resource failed to call close.
I/BufferQueueProducer(18557): [SurfaceView[com.example.meetbin/com.example.meetbin.MainActivity]#5(BLAST Consumer)5](id:487d00000006,api:1,p:18557,c:18557) disconnect: api 1
I/BufferQueueProducer(18557): [SurfaceView[com.example.meetbin/com.example.meetbin.MainActivity]#5(BLAST Consumer)5](id:487d00000006,api:0,p:-1,c:18557) disconnect: api -1
I/BufferQueueProducer(18557): [ViewRootImpl[MainActivity]#4(BLAST Consumer)4](id:487d00000005,api:1,p:18557,c:18557) disconnect: api 1
I/BLASTBufferQueue(18557): [ViewRootImpl[MainActivity]#4] destructor()
I/BufferQueueConsumer(18557): [ViewRootImpl[MainActivity]#4(BLAST Consumer)4](id:487d00000005,api:0,p:-1,c:18557) disconnect
D/DecorView[](18557): onWindowFocusChanged hasWindowFocus false

i was facing the same issue now fixed by following this #1085
to fix this just use this better_player version :
replace
better_player: ^0.0.83
by
better_player:
git:
url: https://github.com/tintran-dev/betterplayer.git
also make sure you have added the formatType for m3u8 and mdp
BetterPlayerDataSource dataSource = BetterPlayerDataSource(
BetterPlayerDataSourceType.network,
"url",
videoFormat: BetterPlayerVideoFormat.hls,
drmConfiguration: BetterPlayerDrmConfiguration(
drmType: BetterPlayerDrmType.token,
token: "Bearer=token",
),
);

Related

The Android view returned from PlatformView was already added to a parent view

I encountered this error but I got no luck in finding a solution on this. Any idea on how I can resolve or at least try to understand what is the issue? Thanks!
E/flutter (18634): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: The Android view returned from PlatformView#getView() was already added to a parent view.
E/flutter (18634): at io.flutter.plugin.platform.PlatformViewsController$1.createForTextureLayer(PlatformViewsController.java:238)
E/flutter (18634): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:122)
E/flutter (18634): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:60)
E/flutter (18634): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/flutter (18634): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/flutter (18634): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/flutter (18634): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/flutter (18634): at android.os.Handler.handleCallback(Handler.java:938)
E/flutter (18634): at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter (18634): at android.os.Looper.loopOnce(Looper.java:226)
E/flutter (18634): at android.os.Looper.loop(Looper.java:313)
E/flutter (18634): at android.app.ActivityThread.main(ActivityThread.java:8751)
E/flutter (18634): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (18634): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
E/flutter (18634): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
E/flutter (18634): , null, null)
E/flutter (18634): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
E/flutter (18634): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:296:18)
E/flutter (18634): <asynchronous suspension>
E/flutter (18634): #2 TextureAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1146:18)
E/flutter (18634): <asynchronous suspension>
E/flutter (18634): #3 AndroidViewController.create (package:flutter/src/services/platform_views.dart:792:5)
E/flutter (18634): <asynchronous suspension>
I tried to check the layout explorer but I haven't see any PlatformView so I'm stuck.

error when using better player in flutter

E/MethodChannel#better_player_channel: Failed to handle method call
java.lang.NullPointerException: MediaSource.Factory#setDrmSessionManagerProvider no longer handles null by instantiating a new DefaultDrmSessionManagerProvider. Explicitly construct and pass an instance in order to retain the old behavior.
at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:174)
at com.google.android.exoplayer2.source.ProgressiveMediaSource$Factory.setDrmSessionManagerProvider(ProgressiveMediaSource.java:186)
at com.jhomlala.better_player.BetterPlayer.buildMediaSource(BetterPlayer.kt:430)
at com.jhomlala.better_player.BetterPlayer.setDataSource(BetterPlayer.kt:196)
at com.jhomlala.better_player.BetterPlayerPlugin.setDataSource(BetterPlayerPlugin.kt:277)
at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:151)
at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:138)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8633)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
E/flutter: [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, MediaSource.Factory#setDrmSessionManagerProvider no longer handles null by instantiating a new DefaultDrmSessionManagerProvider. Explicitly construct and pass an instance in order to retain the old behavior., null, java.lang.NullPointerException: MediaSource.Factory#setDrmSessionManagerProvider no longer handles null by instantiating a new DefaultDrmSessionManagerProvider. Explicitly construct and pass an instance in order to retain the old behavior.
at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:174)
at com.google.android.exoplayer2.source.ProgressiveMediaSource$Factory.setDrmSessionManagerProvider(ProgressiveMediaSource.java:186)
at com.jhomlala.better_player.BetterPlayer.buildMediaSource(BetterPlayer.kt:430)
at com.jhomlala.better_player.BetterPlayer.setDataSource(BetterPlayer.kt:196)
at com.jhomlala.better_player.BetterPlayerPlugin.setDataSource(BetterPlayerPlugin.kt:277)
at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:151)
at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:138)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8633)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:296:18)
#2 MethodChannelVideoPlayer.setDataSource (package:better_player/src/video_player/method_channel_video_player.dart:118:5)
#3 VideoPlayerController._setDataSource (package:better_player/src/video_player/video_player.dart:408:5)
#4 BetterPlayerController._setupDataSource (package:better_player/src/core/better_player_controller.dart:444:9)
#5 BetterPlayerController.setupDataSource (package:better_player/src/core/better_player_controller.dart:274:5)
I face this problem when I use better_player in flutter, It was work good but now show this problem .
Any one can help me

how to run tensorflow lite movenet lightning model with flutter?

TFLite (movenet/multipose/lightning/tflite/float16)
I have loaded the model successfully but whenever I tried to run it... it just crashes the
app.
here is the code for loading and running the model:
Future loadModel() async {
try {
res = await Tflite.loadModel(
model:
"assets/lite-model_movenet_multipose_lightning_tflite_float16_1.tflite",
);
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> model loaded: " + res.toString());
} catch (e) {
print(e);
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Failed to load model.');
} }
Future poseNet(File image) async {
int startTime = new DateTime.now().millisecondsSinceEpoch;
var output = await Tflite.runPoseNetOnImage(
threshold: 0.7,
path: image.path,
numResults: 5,
nmsRadius: 15
);
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> recognitions: ${output}');
setState(() {
_recognitions = output!;
});
int endTime = new DateTime.now().millisecondsSinceEpoch;
print(
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Inference took ${endTime - startTime}ms ");}
here are the logs:
I/tflite (11904): Initialized TensorFlow Lite runtime.
I/flutter (11904): >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> model loaded: success
W/System (11904): A resource failed to call close.
D/EGL_emulation(11904): eglCreateContext: 0xead612c0: maj 2 min 0 rcv 2
E/flutter (11904): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(Failed to run model, length=3; index=3, java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
E/flutter (11904): at sq.flutter.tflite.TflitePlugin.initPoseNet(TflitePlugin.java:1262)
E/flutter (11904): at sq.flutter.tflite.TflitePlugin$RunPoseNet.<init>(TflitePlugin.java:1290)
E/flutter (11904): at sq.flutter.tflite.TflitePlugin.runPoseNetOnImage(TflitePlugin.java:1217)
E/flutter (11904): at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:179)
E/flutter (11904): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/flutter (11904): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:178)
E/flutter (11904): at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0$DartMessenger(DartMessenger.java:206)
E/flutter (11904): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$6ZD1MYkhaLxyPjtoFDxe45u43DI.run(Unknown Source:12)
E/flutter (11904): at android.os.Handler.handleCallback(Handler.java:938)
E/flutter (11904): at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter (11904): at android.os.Looper.loop(Looper.java:223)
E/flutter (11904): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/flutter (11904): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (11904): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/flutter (11904): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/flutter (11904): , null)
E/flutter (11904): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter (11904): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter (11904): <asynchronous suspension>
E/flutter (11904): #2 Tflite.runPoseNetOnImage (package:tflite/tflite.dart:350:12)
E/flutter (11904): <asynchronous suspension>
E/flutter (11904): #3 _SelectImageState.poseNet (package:model_ui/main/select_image.dart:105:18)
E/flutter (11904): <asynchronous suspension>
E/flutter (11904):
any help will be appreciated!
thank you!
I'm not an expert. But tflite plugin is out of date. You should try your luck with the tflite_flutter, which is also a bit outdated. But worked for me.

Flutter local notifications throwing an error

While trying to show the notifications from flutter_local_notification it throws the following error:
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): Failed to handle method call
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.setSmallIcon(FlutterLocalNotificationsPlugin.java:188)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:146)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:688)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:827)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:750)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at android.os.MessageQueue.next(MessageQueue.java:325)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at android.os.Looper.loop(Looper.java:142)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at android.app.ActivityThread.main(ActivityThread.java:6494)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
E/MethodChannel#dexterous.com/flutter/local_notifications(10962): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
E/flutter (10962): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference, null)
E/flutter (10962): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (10962): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
E/flutter (10962): <asynchronous suspension>
E/flutter (10962): #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
E/flutter (10962): #3 AndroidFlutterLocalNotificationsPlugin.show (package:flutter_local_notifications/src/platform_flutter_local_notifications.dart:137:21)
E/flutter (10962): #4 FlutterLocalNotificationsPlugin.show (package:flutter_local_notifications/src/flutter_local_notifications_plugin.dart:136:13)
E/flutter (10962): #5 NotificationPlugin.showNotification (package:pig_salang/models/notification_plugin.dart:94:43)
E/flutter (10962): #6 WelcomeScreen.build.<anonymous closure> (package:pig_salang/screens/welcome_screen.dart:42:36)
E/flutter (10962): #7 WelcomeScreen.build.<anonymous closure> (package:pig_salang/screens/welcome_screen.dart:41:26)
E/flutter (10962): #8 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
E/flutter (10962): #9 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:862:36)
E/flutter (10962): #10 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (10962): #11 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
E/flutter (10962): #12 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
E/flutter (10962): #13 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:217:7)
E/flutter (10962): #14 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9)
E/flutter (10962): #15 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter (10962): #16 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
E/flutter (10962): #17 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
E/flutter (10962): #18 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
E/flutter (10962): #19 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
E/flutter (10962): #20 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter (10962): #21 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (10962): #22 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (10962): #23 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (10962): #24 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (10962): #25 _rootRunUnary (dart:async/zone.dart:1196:13)
E/flutter (10962): #26 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (10962): #27 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (10962): #28 _invoke1 (dart:ui/hooks.dart:275:10)
E/flutter (10962): #29 _dispatchPointerDataPacket (dart:ui/hooks.dart:184:5)
E/flutter (10962):
As far as I have researched, the similar errors were shown because of the icon. I have added used every possible way to add icons, but it is not throwing the error constantly. Obviously, I rerun the app after each changes, to make sure I don't get the error.
My code looks like:
initializePlatformSpecifics() {
var initializeAndroidSettings = AndroidInitializationSettings('app_icon'); <--- Here
var initializeIOSSettings = IOSInitializationSettings(
requestAlertPermission: false,
requestBadgePermission: true,
requestSoundPermission: true,
onDidReceiveLocalNotification: (id, title, body, payload) async {
ReceivedNotification receivedNotification = ReceivedNotification(
id: id, title: title, body: body, payload: payload);
didReceivedLocalNotificationSubject.add(receivedNotification);
},
);
initializeSettings = InitializationSettings(
initializeAndroidSettings, initializeIOSSettings);
}
I followed the tutorial. The thing is when I try to show the notification, it shows the above traceback.
I made notification icons in Android Studio -> app -> main -> res -> Image Asssets -> Notifications icon, then I made icon with name app_icon which I used to intialize the notification.
As it was not working, I also tried :
var initializeAndroidSettings = AndroidInitializationSettings('#mipmap/ic_launcher');
It also did not work. Any help would be appreciated!!!
'app_icon' was given for reference and it actually depends on where you image file is located, if you are using the default icon in mipmap folder named as ic_launcher for now then try the below code. Do let me know if it helps.
var initializeAndroidSettings
=AndroidInitializationSettings('mipmap/ic_launcher');

Error: Unable to handle function call in Cloud Functions Firestore

I want to receive the document form current user uid passed at client side. I tried it using functions.onRequest and successfully got the result but I got the error that while using onCall method.
Cloud Function
exports.getUserData = functions.https.onCall((data) => {
const test = data.text;
db.collection('users').doc(test).get().then((value)=>{
return value.data();
}).catch((e)=>{
return ("Error in CFunction"+e);
})
});
Client-side Call
Future _callable()async{
FirebaseUser currentUser = await _auth.currentUser();
final uid = currentUser.uid;
final HttpsCallable callable =
CloudFunctions.instance.getHttpsCallable(functionName: 'getUserData');
var data = await callable.call(uid);
print(data.data);
}
Error I am getting
E/MethodChannel#cloud_functions(12458): Failed to handle method call
E/MethodChannel#cloud_functions(12458): java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
E/MethodChannel#cloud_functions(12458): at io.flutter.plugins.firebase.cloudfunctions.CloudFunctionsPlugin.onMethodCall(CloudFunctionsPlugin.java:37)
E/MethodChannel#cloud_functions(12458): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
E/MethodChannel#cloud_functions(12458): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#cloud_functions(12458): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
E/MethodChannel#cloud_functions(12458): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#cloud_functions(12458): at android.os.MessageQueue.next(MessageQueue.java:334)
E/MethodChannel#cloud_functions(12458): at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#cloud_functions(12458): at android.app.ActivityThread.main(ActivityThread.java:6939)
E/MethodChannel#cloud_functions(12458): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#cloud_functions(12458): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#cloud_functions(12458): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
E/flutter (12458): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Exception: Unable to call function getUserData
E/flutter (12458): #0 HttpsCallable.call (package:cloud_functions/src/https_callable.dart:50:9)
E/flutter (12458): <asynchronous suspension>
E/flutter (12458): #1 _HomePageState._callable (package:firebaselogin/homepage.dart:160:35)
E/flutter (12458): <asynchronous suspension>
E/flutter (12458): #2 _HomePageState.build.<anonymous closure> (package:firebaselogin/homepage.dart:97:23)
E/flutter (12458): #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
E/flutter (12458): #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:862:36)
E/flutter (12458): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (12458): #6 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
E/flutter (12458): #7 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
E/flutter (12458): #8 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:217:7)
E/flutter (12458): #9 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9)
E/flutter (12458): #10 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter (12458): #11 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
E/flutter (12458): #12 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
E/flutter (12458): #13 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
E/flutter (12458): #14 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
E/flutter (12458): #15 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter (12458): #16 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (12458): #17 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (12458): #18 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (12458): #19 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (12458): #20 _rootRunUnary (dart:async/zone.dart:1196:13)
E/flutter (12458): #21 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (12458): #22 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (12458): #23 _invoke1 (dart:ui/hooks.dart:275:10)
E/flutter (12458): #24 _dispatchPointerDataPacket (dart:ui/hooks.dart:184:5)
Callable functions must return a promise that resolves with the data to send to the client. Right now, your function actually isn't returning anything at all. You should probably return the promise returned by get().
exports.getUserData = functions.https.onCall((data) => {
const test = data.text;
return db.collection('users').doc(test).get();
});