webview打开localNavList中url闪退

来源:12-10 基于自定义WebView实现H5混合开发-3【H5混合实战】

不悔有你ii

2019-04-23

pubspec.yaml中引入依赖

dependencies:
  flutter:
    sdk: flutter
    
  cupertino_icons: ^0.1.2
  flutter_webview_plugin: ^0.3.4

main.dart中代码

import 'package:flutter/material.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return WebviewScaffold(
      url: 'https://m.ctrip.com/html5/you/around',
      appBar: AppBar(
        title: Text(
          'webview页面测试',
        ),
      ),
      withZoom: true,
      withLocalStorage: true,
      hidden: true,
      enableAppScheme: true,
    );
  }
}

android项目中已经修改配置文件兼容androidX,Webview打开https://www.baidu.com没有问题,但是打开localNavList中url的时候应用闪退,错误日志如下:

Launching libmain.dart on Custom Phone in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
Built buildappoutputsapkdebugapp-debug.apk.
Installing buildappoutputsapkapp.apk...
Syncing files to device Custom Phone...
I/Choreographer( 3690): Skipped 173 frames!  The application may be doing too much work on its main thread.
I/OpenGLRenderer( 3690): Davey! duration=3152ms; Flags=1, IntendedVsync=3904996504296, Vsync=3907879837514, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=3907893224864, AnimationStart=3907893248993, PerformTraversalsStart=3907893253650, DrawStart=3907900756749, SyncQueued=3907901733062, SyncStart=3908025127620, IssueDrawCommandsStart=3908025593404, SwapBuffers=3908123830232, FrameCompleted=3908272392456, DequeueBufferDuration=109188000, QueueBufferDuration=218000, 
I/WebViewFactory( 3690): Loading com.android.webview version 66.0.3359.158 (code 336015815)
I/ple.flutter_ap( 3690): The ClassLoaderContext is a special shared library.
I/cr_LibraryLoader( 3690): Time to load native libraries: 42 ms (timestamps 8463-8505)
I/chromium( 3690): [INFO:library_loader_hooks.cc(36)] Chromium logging enabled: level = 0, default verbosity = 0
I/cr_LibraryLoader( 3690): Expected native library version number "66.0.3359.158", actual native library version number "66.0.3359.158"
W/cr_ChildProcLH( 3690): Create a new ChildConnectionAllocator with package name = com.android.webview, sandboxed = true
I/cr_BrowserStartup( 3690): Initializing chromium process, singleProcess=false
I/cr_base ( 3690): Android Locale: zh_CN_#Hans requires .pak files: []
E/chromium( 3690): [ERROR:devtools_http_handler.cc(292)] Cannot start http server for devtools. Stop devtools.
W/cr_CrashFileManager( 3690): /data/user/0/com.example.flutter_app/cache/WebView/Crash Reports does not exist or is not a directory
W/ple.flutter_ap( 3690): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;-><init>(Landroid/content/Context;I)V (light greylist, reflection)
W/ple.flutter_ap( 3690): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->logEvent(Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;)V (light greylist, reflection)
W/ple.flutter_ap( 3690): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionStarted(I)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/ple.flutter_ap( 3690): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(II)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/ple.flutter_ap( 3690): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/ple.flutter_ap( 3690): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextSelection;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/ple.flutter_ap( 3690): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(III)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/ple.flutter_ap( 3690): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(IIILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
D/        ( 3690): HostConnection::get() New Host Connection established 0xc244d6c0, tid 3762
E/cr_ApiBridge( 3690): Failed to init handler: Attempt to invoke virtual method 'java.lang.reflect.Constructor java.lang.Class.getDeclaredConstructor(java.lang.Class[])' on a null object reference
W/cr_media( 3690): Requires BLUETOOTH permission
W/        ( 3690): Unrecognized GLES max version string in extensions: 
E/chromium( 3690): [ERROR:gl_surface_egl.cc(320)] eglChooseConfig failed with error EGL_SUCCESS
E/EGL_emulation( 3690): tid 3762: eglChooseConfig(959): error 0x3004 (EGL_BAD_ATTRIBUTE)
I/Choreographer( 3690): Skipped 41 frames!  The application may be doing too much work on its main thread.
E/chromium( 3690): [ERROR:gl_surface_egl.cc(320)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
E/chromium( 3690): [ERROR:gl_surface_egl.cc(472)] No suitable EGL configs found.
E/chromium( 3690): [ERROR:gl_surface_egl.cc(320)] eglChooseConfig failed with error EGL_SUCCESS
E/EGL_emulation( 3690): tid 3762: eglChooseConfig(959): error 0x3004 (EGL_BAD_ATTRIBUTE)
E/chromium( 3690): [ERROR:gl_surface_egl.cc(320)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
E/chromium( 3690): [ERROR:gl_surface_egl.cc(472)] No suitable EGL configs found.
D/EGL_emulation( 3690): eglCreateContext: 0xbf341de0: maj 2 min 0 rcv 2
I/OpenGLRenderer( 3690): Davey! duration=807ms; Flags=0, IntendedVsync=3908291158570, Vsync=3908974491876, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=3908986245839, AnimationStart=3908986297102, PerformTraversalsStart=3908986554911, DrawStart=3908993851771, SyncQueued=3908994666650, SyncStart=3908994852898, IssueDrawCommandsStart=3908994957740, SwapBuffers=3908996096127, FrameCompleted=3909098598100, DequeueBufferDuration=81780000, QueueBufferDuration=255000, 
W/VideoCapabilities( 3690): Unrecognized profile 4 for video/hevc
D/NetworkSecurityConfig( 3690): No Network Security Config specified, using platform default
I/VideoCapabilities( 3690): Unsupported profile 4 for video/mp4v-es
W/cr_MediaCodecUtil( 3690): HW encoder for video/avc is not available on this device.
E/chromium( 3690): [ERROR:gl_surface_egl.cc(320)] eglChooseConfig failed with error EGL_SUCCESS
E/EGL_emulation( 3690): tid 3762: eglChooseConfig(959): error 0x3004 (EGL_BAD_ATTRIBUTE)
E/chromium( 3690): [ERROR:gl_surface_egl.cc(320)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
E/chromium( 3690): [ERROR:gl_surface_egl.cc(472)] No suitable EGL configs found.
E/chromium( 3690): [ERROR:gl_surface_egl.cc(320)] eglChooseConfig failed with error EGL_SUCCESS
E/EGL_emulation( 3690): tid 3762: eglChooseConfig(959): error 0x3004 (EGL_BAD_ATTRIBUTE)
E/chromium( 3690): [ERROR:gl_surface_egl.cc(320)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
E/chromium( 3690): [ERROR:gl_surface_egl.cc(472)] No suitable EGL configs found.
D/EGL_emulation( 3690): eglCreateContext: 0xbe0142c0: maj 2 min 0 rcv 2
I/chromium( 3690): [INFO:CONSOLE(105)] "A parser-blocking, cross site (i.e. different eTLD+1) script, https://webresource.c-ctrip.com/res/concat?f=%2Fresaresonline%2Ffx%2Flizard22ares%2Fweb%2Flizard.parser.b49776fa.js&pro_20190418172111_, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details.", source: https://webresource.c-ctrip.com/code/lizard/2.2/web/lizard.seed.js (105)
I/chromium( 3690): [INFO:CONSOLE(105)] "A parser-blocking, cross site (i.e. different eTLD+1) script, https://webresource.c-ctrip.com/res/concat?f=%2Fresaresonline%2Ffx%2Flizard22ares%2Fweb%2Flizard.parser.b49776fa.js&pro_20190418172111_, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details.", source: https://webresource.c-ctrip.com/code/lizard/2.2/web/lizard.seed.js (105)
I/chromium( 3690): [INFO:CONSOLE(0)] "Mixed Content: The page at 'https://m.ctrip.com/html5/you/around' was loaded over HTTPS, but requested an insecure image 'http://pic.c-ctrip.com/ZbyH5Pic/h5/scenic_htl/zby_pop.jpg'. This content should also be served over HTTPS.", source: https://m.ctrip.com/html5/you/around (0)
E/chromium( 3690): [ERROR:context_group.cc(137)] ContextResult::kFatalFailure: WebGL1 blacklisted
E/chromium( 3690): [ERROR:context_group.cc(137)] ContextResult::kFatalFailure: WebGL1 blacklisted
I/chromium( 3690): [INFO:CONSOLE(0)] "Mixed Content: The page at 'https://m.ctrip.com/html5/you/around' was loaded over HTTPS, but requested an insecure image 'http://pic.c-ctrip.com/ZbyH5Pic/h5/scenic_htl/zby_pop.jpg'. This content should also be served over HTTPS.", source: https://m.ctrip.com/html5/you/around (0)
E/eglCodecCommon( 3690): glUtilsParamSize: unknow param 0x000088ef
E/eglCodecCommon( 3690): glUtilsParamSize: unknow param 0x000088ef
E/emuglGLESv2_enc( 3690): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetIntegerv:760 GL error 0x500
I/chatty  ( 3690): uid=10074(com.example.flutter_app) Chrome_InProcGp identical 2 lines
E/emuglGLESv2_enc( 3690): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetIntegerv:760 GL error 0x500
E/eglCodecCommon( 3690): glUtilsParamSize: unknow param 0x00009122
E/eglCodecCommon( 3690): glUtilsParamSize: unknow param 0x00009122
E/eglCodecCommon( 3690): glUtilsParamSize: unknow param 0x00009125
E/eglCodecCommon( 3690): glUtilsParamSize: unknow param 0x00009125
E/eglCodecCommon( 3690): glUtilsParamSize: unknow param 0x00008905
E/eglCodecCommon( 3690): glUtilsParamSize: unknow param 0x00008905
E/eglCodecCommon( 3690): glUtilsParamSize: unknow param 0x00008904
E/eglCodecCommon( 3690): glUtilsParamSize: unknow param 0x00008904
E/emuglGLESv2_enc( 3690): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glBindTexture:1945 GL error 0x500
W/google-breakpad( 3690): ### ### ### ### ### ### ### ### ### ### ### ### ###
W/google-breakpad( 3690): Chrome build fingerprint:
W/google-breakpad( 3690): 1.0.0
W/google-breakpad( 3690): 1
W/google-breakpad( 3690): ### ### ### ### ### ### ### ### ### ### ### ### ###
F/libc    ( 3690): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 3762 (Chrome_InProcGp), pid 3690 (ple.flutter_app)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'Android/vbox86p/vbox86p:9/PD1A.180720.031/51:userdebug/test-keys'
Revision: '0'
ABI: 'x86'
pid: 3690, tid: 3762, name: Chrome_InProcGp  >>> com.example.flutter_app <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
    eax c7da2c00  ebx d40a3370  ecx d3ef58ec  edx 0000806f
    edi 0000806f  esi 00000000
    ebp beefa8f8  esp beefa8bc  eip 00000000
backtrace:
    #00 pc 00000000  <unknown>
Application finished.

图片描述
图片描述
不知道原因,麻烦老师看下

写回答

1回答

不悔有你ii

提问者

2019-04-23

//img.mukewang.com/szimg/5cbe76b80001ae7b10802340.jpg

好吧,真机调试没有问题。感觉是genymotion模拟器的问题,尴尬...

1
1
CrazyCodeBoy
好的,加油哦
2019-04-23
共1条回复

Flutter从入门到进阶 实战携程网App 一网打尽核心技术

解锁Flutter开发新姿势,,系统掌握Flutter开发核心技术。

4788 学习 · 3277 问题

查看课程