PlatformException(错误,java.lang.IllegalStateException:尝试创建未注册类型的平台视图:plugins.flutter.io/webview
Posted
技术标签:
【中文标题】PlatformException(错误,java.lang.IllegalStateException:尝试创建未注册类型的平台视图:plugins.flutter.io/webview【英文标题】:PlatformException(error, java.lang.IllegalStateException: Trying to create a platform view of unregistered type: plugins.flutter.io/webview 【发布时间】:2020-08-09 01:16:24 【问题描述】:我已经在我的颤振小部件中为 web 视图尝试了接下来的三个包:
-
https://pub.dev/packages/webview_flutter
https://pub.dev/packages/flutter_inappwebview
https://pub.dev/packages/flutter_webview_plugin
但总是有同样的错误。错误是下一个:
E/flutter (20538): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Trying to create a platform view of unregistered type: plugins.flutter.io/webview
E/flutter (20538): at io.flutter.plugin.platform.PlatformViewsController$1.createPlatformView(PlatformViewsController.java:97)
E/flutter (20538): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:95)
E/flutter (20538): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:59)
E/flutter (20538): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
E/flutter (20538): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter (20538): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
E/flutter (20538): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (20538): at android.os.MessageQueue.next(MessageQueue.java:336)
E/flutter (20538): at android.os.Looper.loop(Looper.java:174)
E/flutter (20538): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/flutter (20538): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (20538): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/flutter (20538): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/flutter (20538): , null)
E/flutter (20538): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (20538): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
E/flutter (20538): <asynchronous suspension>
E/flutter (20538): #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
E/flutter (20538): #3 AndroidViewController._create (package:flutter/src/services/platform_views.dart:633:54)
E/flutter (20538): #4 AndroidViewController.setSize (package:flutter/src/services/platform_views.dart:550:14)
E/flutter (20538): #5 RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:175:29)
E/flutter (20538): #6 RenderAndroidView.performResize (package:flutter/src/rendering/platform_view.dart:156:5)
E/flutter (20538): #7 RenderObject.layout (package:flutter/src/rendering/object.dart:1746:9)
E/flutter (20538): #8 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13)
E/flutter (20538): #9 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
E/flutter (20538): #10 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13)
E/flutter (20538): #11 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
E/flutter (20538): #12 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:808:17)
E/flutter (20538): #13 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
E/flutter (20538): #14 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:171:11)
E/flutter (20538): #15 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:484:7)
E/flutter (20538): #16 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:240:7)
E/flutter (20538): #17 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:399:14)
E/flutter (20538): #18 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
E/flutter (20538): #19 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13)
E/flutter (20538): #20 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
E/flutter (20538): #21 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13)
E/flutter (20538): #22 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1248:11)
E/flutter (20538): #23 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
E/flutter (20538): #24 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13)
E/flutter (20538): #25 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
E/flutter (20538): #26 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13)
E/flutter (20538): #27 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
E/flutter (20538): #28 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13)
E/flutter (20538): #29 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
E/flutter (20538): #30 RenderProxyBoxMixin.performLayout (packa
我也尝试过更改 minSdkVersion 20 但有同样的错误,提到了here。
这是我的“颤振医生-v”
/Users/taz/Desktop/flutter/bin/flutter doctor --verbose
Unable to find any JVMs matching version "1.8".
Unable to find any JVMs matching version "1.8".
[✓] Flutter (Channel beta, v1.17.0-3.2.pre, on Mac OS X 10.15.4 19E287, locale en-GE)
• Flutter version 1.17.0-3.2.pre at /Users/taz/Desktop/flutter
• Framework revision 2a7bc389f2 (3 days ago), 2020-04-21 20:34:20 -0700
• Engine revision 4c8c31f591
• Dart version 2.8.0 (build 2.8.0-dev.20.10)
Unable to find any JVMs matching version "1.8".
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/taz/Library/Android/sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: /usr/bin/java
• Java version Java(TM) SE Runtime Environment 18.9 (build 11.0.4+10-LTS)
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions.
[✓] Xcode - develop for ios and macOS (Xcode 11.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4.1, Build version 11E503a
• CocoaPods version 1.8.3
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
[!] IntelliJ IDEA Community Edition (version 2020.1)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
! Doctor found issues in 3 categories.
Process finished with exit code 0
我能做什么? :)
【问题讨论】:
【参考方案1】:运行 flutter clean,然后在您的模拟器上重新启动应用程序。在此之后,该插件开始为我工作。
【讨论】:
【参考方案2】:我更新了我的插件flutter_inappwebview!在撰写本文时,最新版本为 3.3.0+3
。
它有很多新的事件、方法和选项来控制 WebView。
【讨论】:
我正在使用最新的flutter_inappwebview:^4.0.0+4,但我遇到了上述问题。有什么解决办法吗?【参考方案3】:我从 Github 存储库下载了完整的插件,并根据example/lib/main.dart
文件进行了更正。
【讨论】:
以上是关于PlatformException(错误,java.lang.IllegalStateException:尝试创建未注册类型的平台视图:plugins.flutter.io/webview的主要内容,如果未能解决你的问题,请参考以下文章
PlatformException(错误,java.lang.IllegalStateException:尝试创建未注册类型的平台视图:plugins.flutter.io/webview
当我尝试使用地理编码器获取地址时,给出“未处理的异常:PlatformException(失败,失败,null)”的运行时错误
我在我的颤振应用程序中将 Paytm 全部用于一个 sdk。它抛出 PlatformException 错误