flutter 在Android上webview兼容问题
问题描述
原来 使用了
webview_flutter ^4.8.0
又集成了cloudflare_turnstile: ^0.4.2
导致如下报错:
原因分析:cloudflare_turnstile
依赖的webview 与 webview_flutter
有冲突
✅ 解决方法 删除 webview_flutter ^4.8.0
使用 flutter_inappwebview
平替
环境
macOS 14.3 (23D56) M3 pro 芯片
Android Studio Koala | 2024.1.1
Build #AI-241.15989.150.2411.11948838, built on June 11, 2024
Flutter 3.22.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 761747bfc5 (5 weeks ago) • 2024-06-05 22:15:13 +0200
Engine • revision edd8546116
Tools • Dart 3.4.3 • DevTools 2.34.3
Performing hot restart...
Syncing files to device M2002J9E...
D/AppScoutStateMachine( 8576): 8576-ScoutStateMachinecreated
D/SurfaceView( 8576): UPDATE Surface(name=SurfaceView[com.pixverse.pixverse/com.example.flutter_project.MainActivity])/@0xe4e77c2, mIsProjectionMode = false
D/SurfaceControl( 8576): nativeSetScreenProjection ===> setScreenProjection
D/SurfaceControl( 8576): nativeSetScreenProjection ===> setScreenProjection
D/SurfaceControl( 8576): nativeSetScreenProjection ===> setScreenProjection
I/OpenGLRenderer( 8576): Davey! duration=610891ms; Flags=1, FrameTimelineVsyncId=272802, IntendedVsync=92246879199134, Vsync=92246879199134, InputEventId=0, HandleInputStart=92246880408193, AnimationStart=92246880409495, PerformTraversalsStart=92246880410485, DrawStart=92246881845902, FrameDeadline=92246912532466, FrameInterval=92246880383297, FrameStartTime=16666666, SyncQueued=92246884542724, SyncStart=92246884673766, IssueDrawCommandsStart=92246885777308, SwapBuffers=92246903076474, FrameCompleted=92857771000564, DequeueBufferDuration=745000, QueueBufferDuration=1120625, GpuCompleted=92857771000564, SwapBuffersCompleted=92246904681995, DisplayPresentTime=0,
D/DecorView: onWindowFocusChanged hasWindowFocus true
Restarted application in 2,759ms.
[GETX] Instance "GetMaterialController" has been created
[GETX] Instance "GetMaterialController" has been initialized
I/flutter ( 8576): generateRoutes=========
I/flutter ( 8576): /
I/flutter ( 8576): {}
D/permissions_handler( 8576): No permissions found in manifest for: []3
D/permissions_handler( 8576): No permissions found in manifest for: []3
D/permissions_handler( 8576): No permissions found in manifest for: []3
D/InAppWebView( 8576): Using InAppWebViewClientCompat implementation
W/cr_WebSettings( 8576): setForceDark() is a no-op in an app with targetSdkVersion>=T
W/cr_SupportWebSettings( 8576): setForceDarkBehavior() is a no-op in an app with targetSdkVersion>=T
E/MethodChannel#flutter/platform_views( 8576): Failed to handle method call
E/MethodChannel#flutter/platform_views( 8576): java.lang.RuntimeException: Unknown feature SUPPRESS_ERROR_PAGE
E/MethodChannel#flutter/platform_views( 8576): at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:649)
E/MethodChannel#flutter/platform_views( 8576): at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:618)
E/MethodChannel#flutter/platform_views( 8576): at androidx.webkit.WebViewFeature.isFeatureSupported(WebViewFeature.java:611)
E/MethodChannel#flutter/platform_views( 8576): at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.InAppWebView.prepare(InAppWebView.java:436)
E/MethodChannel#flutter/platform_views( 8576): at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.FlutterWebView.<init>(FlutterWebView.java:82)
E/MethodChannel#flutter/platform_views( 8576): at com.pichillilorenzo.flutter_inappwebview_android.webview.FlutterWebViewFactory.create(FlutterWebViewFactory.java:67)
E/MethodChannel#flutter/platform_views( 8576): at io.flutter.plugin.platform.PlatformViewsController.createPlatformView(PlatformViewsController.java:523)
E/MethodChannel#flutter/platform_views( 8576): at io.flutter.plugin.platform.PlatformViewsController$1.createForPlatformViewLayer(PlatformViewsController.java:168)
E/MethodChannel#flutter/platform_views( 8576): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:105)
E/MethodChannel#flutter/platform_views( 8576): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:55)
E/MethodChannel#flutter/platform_views( 8576): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/MethodChannel#flutter/platform_views( 8576): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/MethodChannel#flutter/platform_views( 8576): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#flutter/platform_views( 8576): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#flutter/platform_views( 8576): at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#flutter/platform_views( 8576): at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#flutter/platform_views( 8576): at android.os.Looper.loopOnce(Looper.java:210)
E/MethodChannel#flutter/platform_views( 8576): at android.os.Looper.loop(Looper.java:299)
E/MethodChannel#flutter/platform_views( 8576): at android.app.ActivityThread.main(ActivityThread.java:8292)
E/MethodChannel#flutter/platform_views( 8576): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter/platform_views( 8576): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
E/MethodChannel#flutter/platform_views( 8576): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
E/flutter ( 8576): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, Unknown feature SUPPRESS_ERROR_PAGE, null, java.lang.RuntimeException: Unknown feature SUPPRESS_ERROR_PAGE
E/flutter ( 8576): at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:649)
E/flutter ( 8576): at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:618)
E/flutter ( 8576): at androidx.webkit.WebViewFeature.isFeatureSupported(WebViewFeature.java:611)
E/flutter ( 8576): at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.InAppWebView.prepare(InAppWebView.java:436)
E/flutter ( 8576): at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.FlutterWebView.<init>(FlutterWebView.java:82)
E/flutter ( 8576): at com.pichillilorenzo.flutter_inappwebview_android.webview.FlutterWebViewFactory.create(FlutterWebViewFactory.java:67)
E/flutter ( 8576): at io.flutter.plugin.platform.PlatformViewsController.createPlatformView(PlatformViewsController.java:523)
E/flutter ( 8576): at io.flutter.plugin.platform.PlatformViewsController$1.createForPlatformViewLayer(PlatformViewsController.java:168)
E/flutter ( 8576): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:105)
E/flutter ( 8576): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:55)
E/flutter ( 8576): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/flutter ( 8576): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/flutter ( 8576): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/flutter ( 8576): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/flutter ( 8576): at android.os.Handler.handleCallback(Handler.java:938)
E/flutter ( 8576): at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter ( 8576): at android.os.Looper.loopOnce(Looper.java:210)
E/flutter ( 8576): at android.os.Looper.loop(Looper.java:299)
E/flutter ( 8576): at android.app.ActivityThread.main(ActivityThread.java:8292)
E/flutter ( 8576): at java.lang.reflect.Method.invoke(Native Method)
E/flutter ( 8576): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
E/flutter ( 8576): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
E/flutter ( 8576): )
E/flutter ( 8576): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
E/flutter ( 8576): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
E/flutter ( 8576): <asynchronous suspension>
E/flutter ( 8576): #2 ExpensiveAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1099:5)
E/flutter ( 8576): <asynchronous suspension>
E/flutter ( 8576): #3 AndroidViewController.create (package:flutter/src/services/platform_views.dart:822:5)
E/flutter ( 8576): <asynchronous suspension>
E/flutter ( 8576):
网友评论