Skip to content

Failed to handle method call: Attempt to invoke virtual method 'void android.app.Activity.enterPictureInPictureMode()' on a null object reference #8

@someq

Description

@someq

I am using flutter_android_pip in my Flutter app to enter PiP mode instead of minimizing the app (when user presses home).
It worked fine with code like this:

class _MyWidgetState extends State<MyWidget> with WidgetsBindingObserver {
  ...
  void didChangeAppLifecycleState(AppLifecycleState state) {
     if (state == AppLifecycleState.inactive) {
       _enterPipMode();
     }
     else if (state == AppLifecycleState.resumed) {
       _exitPipMode();
     }
  }
  ...
}

After I have installed Firebase it stopped working with following error:

Failed to handle method call
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.enterPictureInPictureMode()' on a null object reference
	at com.bostrot.flutterandroidpip.FlutterAndroidPipPlugin.onMethodCall(FlutterAndroidPipPlugin.java:26)
	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
	at android.os.MessageQueue.nativePollOnce(Native Method)
	at android.os.MessageQueue.next(MessageQueue.java:325)
	at android.os.Looper.loop(Looper.java:142)
	at android.app.ActivityThread.main(ActivityThread.java:6494)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Note, it still works if Firebase is not initialized in the code.

Also noted deprecation warning on both plugins:

Note: /.../firebase_core-0.7.0/android/src/main/java/io/flutter/plugins/firebase/core/FlutterFirebaseCorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /.../firebase_messaging-8.0.0-dev.15/android/src/main/java/io/flutter/plugins/firebase/messaging/FlutterFirebaseMessagingPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /.../flutter_android_pip-0.0.2/android/src/main/java/com/bostrot/flutterandroidpip/FlutterAndroidPipPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Are these plugins incompatible in some way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions