pichillilorenzo / flutter_inappwebview

A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.
https://inappwebview.dev
Apache License 2.0
3.22k stars 1.58k forks source link

Android issue: Unknown feature SUPPRESS_ERROR_PAGE, webview not displaying at all #2150

Open kasperkowalski opened 4 months ago

kasperkowalski commented 4 months ago

Environment

Technology Version
Flutter version Flutter (Channel stable, 3.22.1)
Plugin version ^6.0.0
Android version Android toolchain - develop for Android devices (Android SDK version 34.0.0)
iOS version 17.2
macOS version macOS 14.1.2 23B92 darwin-arm64
Xcode version 15.1
Google Chrome version 124.0.6367.179
Gradle 8.4

Device information: | SM G950F (mobile) | android-arm64 | Android 9 (API 28) | | sdk gphone64 arm64 (mobile) | android-arm64 | Android 13 (API 33) (emulator) |

Description

Expected behavior: Widget with webview should be visible.

Current behavior: Widget with webview is not visible on Android after upgrade plugin to v.6.0.0, worked fine on v.5.8.0 and is working fine on iOS in both versions.

Steps to reproduce

  1. Widget code:
    
    Widget build(BuildContext context) {

final html = """

$replacedHtml

""";

final Widget webviewWidget = SizedBox(
  height: height,
  width: double.infinity,
  child: InAppWebView(
    initialData: InAppWebViewInitialData(data: html),
    initialSettings: InAppWebViewSettings(
      transparentBackground: true,
      supportZoom: false,
      disableHorizontalScroll: true,
      disableVerticalScroll: true,
    ),
    onWebViewCreated: (InAppWebViewController controller) {
      controller.addJavaScriptHandler(
        handlerName: 'newHeight',
        callback: (List<dynamic> arguments) async {
          final contentHeight = await controller.getContentHeight();
          final zoomScale = await controller.getZoomScale();
          final htmlHeight = contentHeight!.toDouble() * zoomScale!;
          final htmlHeightFixed =
              double.parse(htmlHeight.toStringAsFixed(2));
          if (htmlHeightFixed == 0.0) {
            return;
          }

          final int? innerHeight;
          if (arguments.isNotEmpty) {
            innerHeight = arguments[0] as int;
          } else {
            innerHeight = await controller.getContentHeight();
          }

          if (mounted) {
            setState(
              () =>
                  height = (innerHeight != null &&
                          innerHeight.toDouble() > htmlHeightFixed)
                      ? innerHeight.toDouble()
                      : htmlHeightFixed,
            );
          }
        },
      );
    },
  ),
);

if (widget.disablePadding ?? false) {
  return webviewWidget;
}

return Column(
  children: [
    TabletMargins(
      mobilePadding: AppSpacing.lg,
      child: webviewWidget,
    ),
    const SizedBox(),
  ],
);
2. console output:
```log
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 0
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 1
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 0
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 1
I/flutter (16853): Fetching article: 40431721
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 0
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 1
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 0
D/InAppWebView(16853): Using InAppWebViewClientCompat implementation
W/cr_SupportWebSettings(16853): setForceDark() is a no-op in an app with targetSdkVersion>=T
W/cr_SupportWebSettings(16853): setForceDarkBehavior() is a no-op in an app with targetSdkVersion>=T
E/MethodChannel#flutter/platform_views(16853): Failed to handle method call
E/MethodChannel#flutter/platform_views(16853): java.lang.RuntimeException: Unknown feature SUPPRESS_ERROR_PAGE
E/MethodChannel#flutter/platform_views(16853):  at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:640)
E/MethodChannel#flutter/platform_views(16853):  at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:609)
E/MethodChannel#flutter/platform_views(16853):  at androidx.webkit.WebViewFeature.isFeatureSupported(WebViewFeature.java:600)
E/MethodChannel#flutter/platform_views(16853):  at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.InAppWebView.prepare(InAppWebView.java:436)
E/MethodChannel#flutter/platform_views(16853):  at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.FlutterWebView.<init>(FlutterWebView.java:82)
E/MethodChannel#flutter/platform_views(16853):  at com.pichillilorenzo.flutter_inappwebview_android.webview.FlutterWebViewFactory.create(FlutterWebViewFactory.java:67)
E/MethodChannel#flutter/platform_views(16853):  at io.flutter.plugin.platform.PlatformViewsController.createPlatformView(PlatformViewsController.java:525)
E/MethodChannel#flutter/platform_views(16853):  at io.flutter.plugin.platform.PlatformViewsController$1.createForPlatformViewLayer(PlatformViewsController.java:170)
E/MethodChannel#flutter/platform_views(16853):  at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:105)
E/MethodChannel#flutter/platform_views(16853):  at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:55)
E/MethodChannel#flutter/platform_views(16853):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/MethodChannel#flutter/platform_views(16853):  at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/MethodChannel#flutter/platform_views(16853):  at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#flutter/platform_views(16853):  at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#flutter/platform_views(16853):  at android.os.Handler.handleCallback(Handler.java:873)
E/MethodChannel#flutter/platform_views(16853):  at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#flutter/platform_views(16853):  at android.os.Looper.loop(Looper.java:214)
E/MethodChannel#flutter/platform_views(16853):  at android.app.ActivityThread.main(ActivityThread.java:7050)
E/MethodChannel#flutter/platform_views(16853):  at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter/platform_views(16853):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E/MethodChannel#flutter/platform_views(16853):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
[log] PlatformException(error, Unknown feature SUPPRESS_ERROR_PAGE, null, java.lang.RuntimeException: Unknown feature SUPPRESS_ERROR_PAGE
        at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:640)
        at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:609)
        at androidx.webkit.WebViewFeature.isFeatureSupported(WebViewFeature.java:600)
        at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.InAppWebView.prepare(InAppWebView.java:436)
        at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.FlutterWebView.<init>(FlutterWebView.java:82)
        at com.pichillilorenzo.flutter_inappwebview_android.webview.FlutterWebViewFactory.create(FlutterWebViewFactory.java:67)
        at io.flutter.plugin.platform.PlatformViewsController.createPlatformView(PlatformViewsController.java:525)
        at io.flutter.plugin.platform.PlatformViewsController$1.createForPlatformViewLayer(PlatformViewsController.java:170)
        at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:105)
        at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:55)
        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
        at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
        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:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7050)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
      )
[log] #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
      #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
      <asynchronous suspension>
      #2      ExpensiveAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1099:5)
      <asynchronous suspension>
      #3      AndroidViewController.create (package:flutter/src/services/platform_views.dart:822:5)
      <asynchronous suspension>
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 1
github-actions[bot] commented 4 months ago

👋 @kasperkowalski

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

kasperkowalski commented 4 months ago

after some debugging I've noticed it's not the issue of version 6.0.0, it was working correctly on that version yesterday, i'm going to make some more checks what has changed

AmitBhandari7777 commented 4 months ago

@kasperkowalski

Did you find the solution??

I had same issue when I upgraded to flutter_inappwebview 6.0.0 and upgrading flutter on May 22,2024. For temporary solution I have switched back to 5.8.0.

kasperkowalski commented 4 months ago

I'm not yet 100% sure but I think the issue was caused by bumping other dependency: webview_flutter_android from version 3.16.1 to 3.16.2 it's changelog says for this version: Bumps androidx.webkit:webkit from 1.7.0 to 1.10.0.

SuhwanCha commented 4 months ago

I'm not yet 100% sure but I think the issue was caused by bumping other dependency: webview_flutter_android from version 3.16.1 to 3.16.2 it's changelog says for this version: Bumps androidx.webkit:webkit from 1.7.0 to 1.10.0.

This also works for me. I had webview_flutter_android dependency in other packages, but it works when I fixed it to 3.16.1. webview_flutter_android 3.16.2 was released 21 hours ago. It's an issue that happened after that

https://pub.dev/packages/webview_flutter_android/versions

Dkdeveloper24 commented 4 months ago

I'm using the webview 6.0.0 in flutterflow. For me downgrading webview_flutter_android is not solving the issue. Any solution?

kasperkowalski commented 4 months ago

@Dkdeveloper24 maybe some other library in your stack is using never version of androidx.webkit:webkit, but first I would check if correct version is added to dependency overrides and all caches are clear.

jlcool commented 4 months ago
dependency_overrides:
  webview_flutter_android: 3.16.1
NoboChai commented 4 months ago

In my case, to avoid the error, webview_flutter_android: 3.16.1 In addition to doing this in /myproject/android/app/build.gradle dependencies { implementation("com.google.android.gms:play-services-ads:23.1.0") } part of "com.google.android.gms:play-services-ads:23.0.0" I had to downgrade to .

ttb-inc commented 4 months ago
dependency_overrides:
  webview_flutter_android: 3.16.1

In my case, this worked for me. I hope to have the package stabilised soon.

Thanks a lot.

nilotpalkapri commented 4 months ago

As per my observation, webview_flutter_android: 3.16.1; com.google.android.gms:play-services-ads:23.0.0 this two solved the issue.

cloudygeek commented 4 months ago

Same issue, and even using dependency_overrides: webview_flutter_android: 3.16.1 doesn't fix. have deleted all ~/.pub-cache, same.

mahitechnologies259 commented 4 months ago

Any latest Solutions?

ThanhPhungTien commented 4 months ago

In my case, go back to 5.8.0 worked for me.

dileepvarmau commented 4 months ago

In my case switching the flutter sdk back to 3.19.6 stable version and dependency_overrides of webview_flutter_android to 3.16.1 worked.

hisham-safade commented 4 months ago

dependency_overrides: webview_flutter_android: 3.16.1 worked for me thank you.

Aleksandar1204 commented 4 months ago

I had the same problem on InAppWebView plugin v.6.0.0, any update?

ayechan-maung commented 4 months ago

dependency_overrides:

is not work for me (;

AYoungXXX commented 4 months ago
dependency_overrides:
  webview_flutter_android: 3.16.1

I had the same problem with oppo phones and it worked

a-v-ebrahimi commented 4 months ago

Same problem here, this solved it :

    dependency_overrides:
      webview_flutter_android: 3.16.1
emadzeebrix305 commented 4 months ago

Same problem here, this solved it :

    dependency_overrides:
      webview_flutter_android: 3.16.1

Thanks this wokred for me on android 13

dooully commented 4 months ago

Same problem here, this solved it :

    dependency_overrides:
      webview_flutter_android: 3.16.1

Thank you. It helped me, too.

MariusBelciug commented 4 months ago

I had the same issue and moving back to flutter_inappwebview: ^5.8.0 solved it.

shivam2702 commented 4 months ago

Do anyone know the ticket in android regarding this issue?

moshe5745 commented 4 months ago

Do anyone know the ticket in android regarding this issue?

Don’t think this is there issue

This library relies on the flutter_android_webview that is used by the flutter_webview and maintained by Google folks. If they changed something in there api this library(flutter_inappwebview) must fix this issue.

JgomesAT commented 3 months ago

I have the same problem, any schedule to correct this?

MMoarales commented 3 months ago

same problem , i fond remove google_mobile_ads is ok . Please fix this, it's killing me

Try this, it works for me.

dependency_overrides:
  webview_flutter_android: 3.16.1
ShafieaGabr commented 3 months ago
dependency_overrides:
  webview_flutter_android: 3.16.1

worked for me.. thanks

najmulmyself commented 3 months ago

had the same problem. this snippet fixed my code:

<meta-data android:name="android.webkit.WebView.EnableSafeBrowsing" android:value="true" /> <meta-data android:name="flutterEmbedding" android:value="2" />

harry-odinson-369 commented 3 months ago
dependency_overrides:
  webview_flutter_android: 3.16.1

This also worked for me!

JgomesAT commented 3 months ago

HI,

this work dependency_overrides: webview_flutter_android: 3.16.1

but any prevision for a final solution

rkverma2022 commented 3 months ago

In my case, to avoid the error, webview_flutter_android: 3.16.1 In addition to doing this in /myproject/android/app/build.gradle dependencies { implementation("com.google.android.gms:play-services-ads:23.1.0") } part of "com.google.android.gms:play-services-ads:23.0.0" I had to downgrade to .

worked for me

Also add permissions follow this doc: https://inappwebview.dev/docs/intro

Manuito83 commented 3 months ago

2182 removes references to SUPPRESS_ERROR_PAGE, which was discontinued in webkit's development.

phamconganh commented 3 months ago

While waiting for the next release, you can hotfix by forcing androidx.webkit:webkit:1.8.0. Add this to android/build.gradle

allprojects {
    /// TODO: remove. hotfix for flutter_inappwebview (using androidx.webkit:webkit:1.8.0)
    /// webview_flutter_android: ^3.16.2 androidx.webkit:webkit ^1.9.0 remove SUPPRESS_ERROR_PAGE
    configurations.all {
        resolutionStrategy {
            force 'androidx.webkit:webkit:1.8.0'
        }
    }
}
nine-zet commented 3 months ago
dependency_overrides:
  webview_flutter_android: 3.16.1

worked for me. thx.

frankenten13 commented 3 months ago

While waiting for the next release, you can hotfix by forcing androidx.webkit:webkit:1.8.0. Add this to android/build.gradle

allprojects {
    /// TODO: remove. hotfix for flutter_inappwebview (using androidx.webkit:webkit:1.8.0)
    /// webview_flutter_android: ^3.16.2 androidx.webkit:webkit ^1.9.0 remove SUPPRESS_ERROR_PAGE
    configurations.all {
        resolutionStrategy {
            force 'androidx.webkit:webkit:1.8.0'
        }
    }
}

worked for me, thanks.

segyoungpark commented 3 months ago

any solutions mentioned here didnt work for me. any other solutions?

esaiamuthan commented 3 months ago

yes same issue for me also SUPPRESS_ERROR_PAGE

segyoungpark commented 3 months ago

yes same issue for me also SUPPRESS_ERROR_PAGE

i solved the problem by doing this! https://sseymorr.github.io/flutter/errors/suppress-error-page/

allprojects {
    configurations.all {
        resolutionStrategy {
            force 'androidx.webkit:webkit:1.8.0'
        }
    }
}
dependency_overrides:
  webview_flutter_android: 3.16.1
foozaweb commented 2 months ago

hot fixing by forcing androidx.webkit:webkit:1.8.0 worked for me. Add this to android/build.gradle

allprojects {

configurations.all {
    resolutionStrategy {
        force 'androidx.webkit:webkit:1.8.0'
    }
}

}

esaiamuthan commented 2 months ago

yes working for me, can you explain why this error came ?

foozaweb commented 2 months ago

yes working for me, can you explain why this error came ?

The error message indicates that there is a problem with the configuration or implementation of the flutter_inappwebview package. The "Unknown feature SUPPRESS_ERROR_PAGE" suggests that the package is trying to use a feature that is not available or not properly configured.

Manuito83 commented 2 months ago

yes working for me, can you explain why this error came ?

I explained the reason here

Xoshbin commented 2 months ago
dependency_overrides:
  webview_flutter_android: 3.16.1

This worked, Thank you

tkreuder commented 2 months ago

hot fixing by forcing androidx.webkit:webkit:1.8.0 worked for me. Add this to android/build.gradle

allprojects {

configurations.all {
    resolutionStrategy {
        force 'androidx.webkit:webkit:1.8.0'
    }
}

}

This solution worked for me.

and this: https://github.com/pichillilorenzo/flutter_inappwebview/pull/2182#issuecomment-2236442823 for me.

Logochega commented 2 months ago

Hello, resolved with the following method, watch the video to understand. Olá resolvido com o seguinte método veja o video para entender.

em pub dependency_overrides: webview_flutter_android: 3.16.1

em build.gradle android/app/build.gradle dependencies { implementation("com.google.android.gms:play-services-ads:23.1.0") } parte de "com.google.android.gms:play-services-ads:23.0.0" tive que fazer o downgrade para .

youtube

felipecastrosales commented 1 month ago

/// TODO: remove. hotfix for flutter_inappwebview (using androidx.webkit:webkit:1.8.0) /// webview_flutter_android: ^3.16.2 androidx.webkit:webkit ^1.9.0 remove SUPPRESS_ERROR_PAGE configurations.all { resolutionStrategy { force 'androidx.webkit:webkit:1.8.0' } }

For some reason, this was the only option that worked for me. Override didn't solve my problem. Thanks @phamconganh

alitalaee commented 3 weeks ago

dependency_overrides: webview_flutter_android: 3.16.1

it is worked for me THANKS

DontSerious commented 2 weeks ago

While waiting for the next release, you can hotfix by forcing androidx.webkit:webkit:1.8.0. Add this to android/build.gradle

allprojects {
    /// TODO: remove. hotfix for flutter_inappwebview (using androidx.webkit:webkit:1.8.0)
    /// webview_flutter_android: ^3.16.2 androidx.webkit:webkit ^1.9.0 remove SUPPRESS_ERROR_PAGE
    configurations.all {
        resolutionStrategy {
            force 'androidx.webkit:webkit:1.8.0'
        }
    }
}

it is worked for me THANKS

ao305 commented 1 week ago

While waiting for the next release, you can hotfix by forcing androidx.webkit:webkit:1.8.0. Add this to android/build.gradle

allprojects {
    /// TODO: remove. hotfix for flutter_inappwebview (using androidx.webkit:webkit:1.8.0)
    /// webview_flutter_android: ^3.16.2 androidx.webkit:webkit ^1.9.0 remove SUPPRESS_ERROR_PAGE
    configurations.all {
        resolutionStrategy {
            force 'androidx.webkit:webkit:1.8.0'
        }
    }
}

it is worked for me THANKS

this solution , it is worked for me , thanks