我有一个带有webview的应用程序。 在该webview中有一个表单:
<select>
<option value='1'>Something</option>
</select>
当点击选择字段时,android将调用android.widget.CheckedTextView
我发现在某些设备上会导致崩溃(请参阅下面的日志)
所以我的问题是,我怎样才能避免这次崩溃? 也许有可能扩展webview并在android调用CheckedTextView之前添加try {}。
android.view.InflateException: Binary XML file line #17: Error inflating class android.widget.CheckedTextView
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:666)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
at android.view.LayoutInflater.inflate(LayoutInflater.java:467)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:371)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
at android.webkit.WebViewClassic$InvokeListBox$MyArrayListAdapter.getView(WebViewClassic.java:12535)
at android.widget.AbsListView.obtainView(AbsListView.java:2472)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1250)
at android.widget.ListView.onMeasure(ListView.java:1162)
at android.view.View.measure(View.java:15575)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1038)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:576)
at android.view.View.measure(View.java:15575)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1038)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:576)
at android.view.View.measure(View.java:15575)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
at android.view.View.measure(View.java:15575)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:15575)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
at android.view.View.measure(View.java:15575)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2423)
at android.view.View.measure(View.java:15575)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2031)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1249)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1425)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1142)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4724)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4947)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:593)
... 57 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_btn_radio_material.xml from drawable resource ID #0x7f020008
at android.content.res.Resources.loadDrawable(Resources.java:2265)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.widget.CheckedTextView.<init>(CheckedTextView.java:67)
at android.widget.CheckedTextView.<init>(CheckedTextView.java:58)
... 60 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_btn_radio_on_mtrl.xml from drawable resource ID #0x7f02000a
at android.content.res.Resources.loadDrawable(Resources.java:2265)
at android.content.res.Resources.getDrawable(Resources.java:977)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:917)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:854)
at android.content.res.Resources.loadDrawable(Resources.java:2262)
... 63 more
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:913)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:854)
at android.content.res.Resources.loadDrawable(Resources.java:2262)
... 68 more
答案 0 :(得分:0)
我发现如果我在build gradle中替换了以下行
compile 'com.android.support:appcompat-v7:23.2.0'
与
compile 'com.android.support:appcompat-v7:23.1.1'
解决了这个问题。
我不完全确定为什么,但显然在appcompat版本中存在一些与早期Android版本不相符的差异。