Skip to content
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

Platform Exception when launching on Android 5.0.2 (API 21) #526

Closed
arnaudelub opened this issue Sep 17, 2020 · 9 comments
Closed

Platform Exception when launching on Android 5.0.2 (API 21) #526

arnaudelub opened this issue Sep 17, 2020 · 9 comments
Labels
bug Something isn't working stale

Comments

@arnaudelub
Copy link

Technology Version
Flutter version 1.20.3 channel stable
Plugin version 4.0.0+4
Android version 5.0.2
iOS version
Xcode version

Device information:
EMULATOR

Description

Running the example throw a platformException

Expected behavior:
inappwebview should print the webpage correclty

Current behavior:
Receiving a platform exception

Steps to reproduce

Stacktrace/Logcat

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h Repeat this help message.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
An Observatory debugger and profiler on Android SDK built for x86 64 is available at: http://127.0.0.1:40979/YO3ZFso62cU=/
E/flutter (11423): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Trying to create a platform view of unregistered type: com.pichillilorenzo/flutter_inappwebview
E/flutter (11423):      at io.flutter.plugin.platform.PlatformViewsController$1.createVirtualDisplayForPlatformView(PlatformViewsController.java:155)
E/flutter (11423):      at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:104)
E/flutter (11423):      at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:59)
E/flutter (11423):      at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:230)
E/flutter (11423):      at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter (11423):      at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/flutter (11423):      at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (11423):      at android.os.MessageQueue.next(MessageQueue.java:143)
E/flutter (11423):      at android.os.Looper.loop(Looper.java:122)
E/flutter (11423):      at android.app.ActivityThread.main(ActivityThread.java:5221)
E/flutter (11423):      at java.lang.reflect.Method.invoke(Native Method)
E/flutter (11423):      at java.lang.reflect.Method.invoke(Method.java:372)
E/flutter (11423):      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/flutter (11423):      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
E/flutter (11423): , null)
E/flutter (11423): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:572:7)
E/flutter (11423): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:161:18)
E/flutter (11423): <asynchronous suspension>
E/flutter (11423): #2      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12)
E/flutter (11423): #3      TextureAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1039:54)
E/flutter (11423): #4      AndroidViewController.create (package:flutter/src/services/platform_views.dart:746:11)
E/flutter (11423): #5      TextureAndroidViewController.create (package:flutter/src/services/platform_views.dart:1017:34)
E/flutter (11423): #6      TextureAndroidViewController.setSize (package:flutter/src/services/platform_views.dart:1001:14)
E/flutter (11423): #7      RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:176:29)
E/flutter (11423): #8      RenderAndroidView.performResize (package:flutter/src/rendering/platform_view.dart:157:5)
E/flutter (11423): #9      RenderObject.layout (package:flutter/src/rendering/object.dart:1748:9)
E/flutter (11423): #10     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
E/flutter (11423): #11     RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
E/flutter (11423): #12     RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:209:11)
E/flutter (11423): #13     RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
E/flutter (11423): #14     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
E/flutter (11423): #15     RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
E/flutter (11423): #16     RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:209:11)
E/flutter (11423): #17     RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
E/flutter (11423): #18     RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:827:17)
E/flutter (11423): #19     RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
E/flutter (11423): #20     RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:209:11)
E/flutter (11423): #21     RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
E/flutter (11423): #22     MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:173:11)
E/flutter (11423): #23     _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:495:7)
E/flutter (11423): #24     MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:242:7)
E/flutter (11423): #25     RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:401:14)
E/flutter (11423): #26     RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
E/flutter (11423): #27     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
E/flutter (11423): #28     RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
E/flutter (11423): #29     RenderProxyBoxMixin.p

Issue in my app with same version of Android

Technology Version
Flutter version 1.20.3 channel stable
Plugin version 4.0.0+4
Android version 5.0.2
iOS version
Xcode version

Device information:
EMULATOR

Description

I am actually using this plugin on the app i am building actually, there is no PlatformException though when launching
the app on Android 5.0.2 but apparently there is an issue with Javascript as controller.evaluateJavascript doesn't work.

Expected behavior:
inappwebview should execute JS correctly

Current behavior:
Nothing happen

Code

InAppWebView(
                  initialUrl: snap.data,
                  initialHeaders: {},
                  initialOptions: InAppWebViewGroupOptions(
                      android: AndroidInAppWebViewOptions(
                          initialScale: 0,
                          useHybridComposition: true,
                          thirdPartyCookiesEnabled: true,
                          safeBrowsingEnabled: false,
                          builtInZoomControls: true,
                          loadWithOverviewMode: true,
                          useWideViewPort: true),
                      crossPlatform: InAppWebViewOptions(
                          debuggingEnabled: false,
                          javaScriptEnabled: true,
                          useShouldOverrideUrlLoading: true,
                          javaScriptCanOpenWindowsAutomatically: true,
                          useOnLoadResource: true)),
                  onWebViewCreated: (InAppWebViewController webViewController) {
                    webview = webViewController;
                  },
                  onLoadResource: (InAppWebViewController controller,
                      LoadedResource resource) {},
                  onCreateWindow: (InAppWebViewController controller,
                      CreateWindowRequest request) async {
                    if (request.url.startsWith(WEB_LINKEDIN_URL) ||
                        request.url.startsWith(WEB_GOOGLE_URL) ||
                        request.url.startsWith(WEB_TELEGRAM_URL) ||
                        request.url.startsWith(WEB_TWITTER_URL) ||
                        request.url.startsWith(WEB_FACEBOOK_URL) ||
                        request.url.startsWith(WEB_FACEBOOK_URL_WWW) ||
                        request.url.startsWith(WEB_WHATSAPP_URL)) {
                      if (isIPad) {
                        await Share.share(
                          actualUrl,
                          sharePositionOrigin: Rect.fromCenter(
                              center: Offset(100, 100),
                              width: 100,
                              height: 100),
                        );
                      } else {
                        Share.share(actualUrl);
                      }
                      return false;
                    } else {
                      isFirstLoad = true;
                      controller.loadUrl(url: request.url);
                      return true;
                    }
                  },
                  shouldOverrideUrlLoading: (InAppWebViewController controller,
                      ShouldOverrideUrlLoadingRequest request) async {
                    if (request.url.startsWith(WEB_LINKEDIN_URL) ||
                        request.url.startsWith(WEB_GOOGLE_URL) ||
                        request.url.startsWith(WEB_TELEGRAM_URL) ||
                        request.url.startsWith(WEB_TWITTER_URL) ||
                        request.url.startsWith(WEB_FACEBOOK_URL) ||
                        request.url.startsWith(WEB_FACEBOOK_URL_WWW) ||
                        request.url.startsWith(WEB_WHATSAPP_URL)) {
                      if (!isIPad) {
                        Share.share(actualUrl);
                      } else {
                        await Share.share(
                          actualUrl,
                          sharePositionOrigin: Rect.fromCenter(
                              center: Offset(100, 100),
                              width: 100,
                              height: 100),
                        );
                      }
                      return ShouldOverrideUrlLoadingAction.CANCEL;
                    }
                    if (request.isForMainFrame) {
                      if (_redirectIfNotEpa(request.url))
                        return ShouldOverrideUrlLoadingAction.CANCEL;
                    }
                    return ShouldOverrideUrlLoadingAction.ALLOW;
                  },
                  onLoadStart: (InAppWebViewController controller, String url) {
                    setState(() {
                      actualUrl = url;
                    });
                  },
                  onLoadStop:
                      (InAppWebViewController controller, String url) async {
                    setState(() {
                      actualUrl = url;
                    });
                    _getDomainActualUrl();
                    final newUrl = await _checkIfWeGotCookie(url);
                    if (isLoggedIn && isFirstLoad && newUrl != url) {
                      isFirstLoad = false;
                      controller.loadUrl(url: newUrl);
                    }
                  },
                  onProgressChanged:
                      (InAppWebViewController controller, int progress) {
                    setState(() {
                      isLoading = progress > 0 && progress < 100;
                      this.progress = progress / 100;
                    });
                  },
                );
@arnaudelub arnaudelub added the bug Something isn't working label Sep 17, 2020
@yashbansal042
Copy link

Any updates on this? I'm facing the same issue.

@stevenlafl
Copy link

stevenlafl commented Nov 30, 2020

The recommended version is still set to 3.4.x so you'll have to manually set it to the latest. As of writing this is: ^4.0.0+4
Cheers!

@simone40love
Copy link

simone40love commented Jan 18, 2021

I also get this error when I run in Release Mode, and include the file_picker plugin. If I remove the file_picker, I don't get an error.

I get it on any API version, not just 21.

E/flutter (26973): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Trying to create a platform view of unregistered type: com.pichillilorenzo/flutter_inappwebview
E/flutter (26973): at io.flutter.plugin.platform.j$a.d(Unknown Source:229)
E/flutter (26973): at io.flutter.embedding.engine.i.i$a.b(Unknown Source:152)
E/flutter (26973): at io.flutter.embedding.engine.i.i$a.k(Unknown Source:144)
E/flutter (26973): at g.a.d.a.j$a.a(Unknown Source:17)
E/flutter (26973): at io.flutter.embedding.engine.e.b.e(Unknown Source:57)
E/flutter (26973): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4)
E/flutter (26973): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (26973): at android.os.MessageQueue.next(MessageQueue.java:326)
E/flutter (26973): at android.os.Looper.loop(Looper.java:181)
E/flutter (26973): at android.app.ActivityThread.main(ActivityThread.java:7156)
E/flutter (26973): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (26973): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E/flutter (26973): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
E/flutter (26973): , null, null)
E/flutter (26973): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582)
E/flutter (26973): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159)
E/flutter (26973):
E/flutter (26973): #2 TextureAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1037)
E/flutter (26973):
E/flutter (26973): #3 AndroidViewController.create (package:flutter/src/services/platform_views.dart:743)
E/flutter (26973):
E/flutter (26973): #4 RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:195)
E/flutter (26973):

@kleeb
Copy link

kleeb commented Jan 25, 2021

any news on this one ?

@pichillilorenzo
Copy link
Owner

Have you tried the latest version?

@1encore
Copy link

1encore commented Jul 20, 2021

I have faced the same on latest version, but found a solution: just flutter clean, close the app on emulator or real device, finally run the app

@mukkumukesh
Copy link

I had tried flutter clean and flutter pub cache repair but not worked. Using the latest version flutter_inappwebview: ^5.7.2+3.

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Trying to create a platform view of unregistered type: com.pichillilorenzo/flutter_inappwebview at io.flutter.plugin.platform.PlatformViewsController$a.m(SourceFile:11) at io.flutter.plugin.platform.PlatformViewsController$a.h(SourceFile:6) at io.flutter.embedding.engine.systemchannels.k$a.b(SourceFile:23) at io.flutter.embedding.engine.systemchannels.k$a.onMethodCall(SourceFile:12) at io.flutter.plugin.common.h$a.a(SourceFile:2) at io.flutter.embedding.engine.dart.c.h(SourceFile:2) at io.flutter.embedding.engine.dart.c.i(SourceFile:3) at io.flutter.embedding.engine.dart.c.j(Unknown Source:0) at io.flutter.embedding.engine.dart.a.run(Unknown Source:12) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8757) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) , null, null) #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653) #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315) <asynchronous suspension> #2 SurfaceAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1017) <asynchronous suspension> #3 AndroidViewController.create (package:flutter/src/services/platform_views.dart:801) <asynchronous suspension> [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method setCookie on channel com.pichillilorenzo/flutter_inappwebview_cookiemanager) #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:313) <asynchronous suspension> #1 CookieManager.setCookie (package:flutter_inappwebview/src/cookie_manager.dart:98) <asynchronous suspension>

Copy link

github-actions bot commented Oct 6, 2024

This issue is stale and has been automatically closed because it has been open for more than 365 days with no activity. Please reopen a new issue if you still have it.

@github-actions github-actions bot added the stale label Oct 6, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 6, 2024
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

8 participants