8000 GitHub Β· Where software is built 8000
[go: up one dir, main page]

Skip to content
Exception when application exits on AndroidΒ #578
Open
@pan1nx

Description

@pan1nx

Describe the bug

When Android application exits (user closes the application), there is an null-pointer exception thrown:

Exception 'java.lang.NullPointerException' occurred in thread 'main' at com.cloudwebrtc.webrtc.FlutterWebRTCPlugin.onDetachedFromActivity(FlutterWebRTCPlugin.java:97)

Suggestion how to fix

In FlutterWebRTCPlugin.java @ L97 (https://github.com/flutter-webrtc/flutter-webrtc/blob/master/android/src/main/java/com/cloudwebrtc/webrtc/FlutterWebRTCPlugin.java#L97) patch it like this:

         if (this.observer != null) {
             this.lifecycle.removeObserver(this.observer);
-            this.application.unregisterActivityLifecycleCallbacks(this.observer);
+            if (this.application != null) {
+                this.application.unregisterActivityLifecycleCallbacks(this.observer);
+            }
         }

To Reproduce

Create an Android application and use flutter_webrtc. When exit the application, the exception is thrown.

Expected behavior

Exit gracefully.

Platform information

  • Flutter version: Flutter (Channel beta, 2.2.0, on Linux, locale en_US.UTF-8), Flutter version 2.2.0, Framework revision b22742018b (3 weeks ago), Engine revision a9d88a4d18, Dart version 2.13.0

  • Plugin version: 0.6.4

  • OS: Android

  • OS version: Any API >= 23 showed same behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0