Skip to content

Fix KeepAlive null error #2638

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mustafayildiz12
Copy link

Versions:
flutter: 3.32.0
flutter_inappwebview: ^6.1.5

Error:

Fatal Exception: java.lang.RuntimeException
Unable to destroy activity {com.limakteknoloji.limakmobile/com.limakteknoloji.limakmobile.MainActivity}: java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.FlutterWebView.keepAliveId' on a null object reference in method 'void com.pichillilorenzo.flutter_inappwebview_android.webview.InAppWebViewManager.dispose()'

Issue Scenario:

  1. This error happens ın android devices only.
  2. If you use keepAlive and try to dispose it, you will get this error when app is terminated.

After getting this NullPointerException I checked the current code and saw this issue in InAppWebViewManager.java

Just use ;

keepAliveWebViews.remove(keepAliveId);

instead of;

if (keepAliveWebViews.containsKey(keepAliveId)) {
keepAliveWebViews.put(keepAliveId, null);
}

Tested on android 12, 13, 14.

@probot-autolabeler probot-autolabeler bot added android iOS macOS macOS platform web windows Windows platform labels Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android iOS macOS macOS platform web windows Windows platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant