为什么带有HTML select标签的Android OS 8 WebVew会使应用程序崩溃

编程入门 行业动态 更新时间:2024-10-07 08:30:09
本文介绍了为什么带有HTML select标签的Android OS 8 WebVew会使应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个混合的Cordova Android应用程序,当用户点击在Android OS 8上运行的WebView中的下拉框时,该应用程序崩溃.我创建了一个带有<select>标签的简单页面并且问题是可重现的.我有一种解决方法,可以自行选择弹出警报,但是只是想知道其他人是否正在发生这种情况,以及这是否是OS8 WebView错误.

I've got a hybrid Cordova Android app, and the app crashes when user tap on a drop-down box in my WebView running on Android OS 8. I've created a simple page with a <select> tag and the issue is reproducible. I've got a workaround which is to do my own pop up alert to select, but just wondering if this is happening to anyone else and whether this is an OS8 WebView bug.

下面是带有<select>标记

www.w3schools/tags/tryit.asp ?filename = tryhtml_select

下面是我的崩溃日志

11:04:58.643 3208-3208/com.****.****E/AndroidRuntime: FATAL EXCEPTION: main Process: com.****.****, PID: 3208 android.content.res.Resources$NotFoundException: Resource ID #0x0 at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:195) at android.content.res.Resources.loadXmlResourceParser(Resources.java:2133) at android.content.res.Resources.getLayout(Resources.java:1142) at android.view.LayoutInflater.inflate(LayoutInflater.java:421) at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:416) at android.widget.ArrayAdapter.getView(ArrayAdapter.java:407) at org.chromium.content.browser.input.SelectPopupAdapter.getView(SelectPopupAdapter.java:53) at android.widget.AbsListView.obtainView(AbsListView.java:2372) at android.widget.ListView.measureHeightOfChildren(ListView.java:1408) at android.widget.ListView.onMeasure(ListView.java:1315) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:721) at android.view.View.measure(View.java:21998) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2410) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1471) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1751) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) at android.view.Choreographer.doCallbacks(Choreographer.java:723) at android.view.Choreographer.doFrame(Choreographer.java:658) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

我的问题与此不同

尝试在Android中打开SELECT标记WebView使应用程序崩溃

2018年1月9日更新: 我还没有解决方案,我的临时解决方法是删除标签,而仅使用输入.当用户选择此元素时,我们会将事件传递给本机代码,以弹出一个供选择的对话框,并在用户做出选择后更新输入.

UPDATE on 9th Jan 2018: I haven't got a solution yet, my temporary workaround is remove the tag and just use an input. When user select this element, we pass the event to native code to pop up a dialog for selection and update the input once user made a selection.

2018年3月23日更新: 经过更多调查后,我注意到只有在WebView位于Fragment中而不是Activity中时,它才会崩溃.

UPDATE on 23rd March 2018: After some more investigation, I noticed that it only crashes if the WebView is in a Fragment, but not in an Activity.

我在这篇文章中发现以下评论:

I found below comments from this post:

尝试在Android中打开SELECT标记WebView使应用程序崩溃

单击SELECT标记后,Android会使用本机AlertDialog在内部显示其选项. Webview必须使用Activity上下文创建,因为AlertDialog实例需要一个Activity上下文."

"When a SELECT tag is clicked, Android internally displays its options using a native AlertDialog. Webview must be created with an Activity context because AlertDialog instance needs an Activity context."

我认为这是Android中的错误,可能无法正确处理Fragment的上下文.

I believe this is a bug in Android, probably not handling Context properly for Fragment.

2018年4月17日更新:

正如kenyee所指出的,从这里 issuetracker.google/issues/77246450 ,Google说

As kenyee pointed out, from here issuetracker.google/issues/77246450, Google says

您一定不能子类化资源对象-从未得到支持,这只是偶然发生的(这就是为什么现在将其标记为已弃用的原因).该框架需要了解所有资源对象,以便它可以在加载Webview时更新它们(因为Webview向资产管理器添加了其他路径).

You mustn't subclass the resources object - this was never supported and was only possible by accident (which is why it's now marked deprecated). The framework needs to know about all the resources objects so that it can update them when webview is loaded (since webview adds additional paths to the asset manager).

编辑2018年11月29日 似乎这个问题困扰了很多人.

Edit 29th November 2018 Seems this issue has bothered a lot of people.

  • 我尝试并测试过的解决方案是不对资源进行子类化.
  • 更新编译sdk和受支持的库版本对某些人有用.
  • 向Resource中添加包装器类可能可行,我在初步调查中尝试了这种方法,它解决了Select崩溃问题,当您单击并按住文本视图以弹出"COPY",粘贴"选项.
推荐答案

类似以下错误: issuetracker.google/issues/77246450

不要子类化资源...显然不会得到修复.

Don't subclass resources...won't be fixed apparently.

更多推荐

为什么带有HTML select标签的Android OS 8 WebVew会使应用程序崩溃

本文发布于:2023-11-05 10:31:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560593.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:会使   应用程序   标签   HTML   select

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!