无暇之泪 2017-11-13 08:58 采纳率: 100%
浏览 7959
已采纳

Android 8.0使用webview加载html崩溃

低于8.0版本则正常使用,错误log如下

 Process: com.dhcc.csr, PID: 10366
                                                              java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dhcc.csr/com.dhcc.csr.news.detail.PartyDynamicDetailActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.webkit.WebView
                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
                                                                  at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
                                                                  at android.os.Handler.dispatchMessage(Handler.java:105)
                                                                  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)
                                                               Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.webkit.WebView
                                                               Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class android.webkit.WebView
                                                               Caused by: java.lang.reflect.InvocationTargetException
                                                                  at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                                  at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
                                                                  at android.view.LayoutInflater.createView(LayoutInflater.java:647)
                                                                  at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
                                                                  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
                                                                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
                                                                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
                                                                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
                                                                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
                                                                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
                                                                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                                                                  at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:418)
                                                                  at android.app.Activity.setContentView(Activity.java:2654)
                                                                  at com.dhcc.csr.news.detail.PartyDynamicDetailActivity.onCreate(PartyDynamicDetailActivity.java:94)
                                                                  at android.app.Activity.performCreate(Activity.java:6975)
                                                                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
                                                                  at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
                                                                  at android.os.Handler.dispatchMessage(Handler.java:105)
                                                                  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)
                                                               Caused by: java.lang.NullPointerException
                                                                  at android.content.res.AssetManager.addAssetPathNative(Native Method)
                                                                  at android.content.res.AssetManager.addAssetPathInternal(AssetManager.java:689)
                                                                  at android.content.res.AssetManager.addAssetPathAsSharedLibrary(AssetManager.java:684)
                                                                  at android.webkit.WebViewFactory.getProviderClass(WebViewFactory.java:407)
                                                                  at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:211)
11-13 16:50:39.410 10366-10366/com.dhcc.csr E/AndroidRuntime:     at android.webkit.WebView.getFactory(WebView.java:2467)
                                                                  at android.webkit.WebView.ensureProviderCreated(WebView.java:2462)
                                                                  at android.webkit.WebView.setOverScrollMode(WebView.java:2527)
                                                                  at android.view.View.<init>(View.java:4536)
                                                                  at android.view.View.<init>(View.java:4668)
                                                                  at android.view.ViewGroup.<init>(ViewGroup.java:597)
                                                                  at android.widget.AbsoluteLayout.<init>(AbsoluteLayout.java:55)
                                                                  at android.webkit.WebView.<init>(WebView.java:636)
                                                                  at android.webkit.WebView.<init>(WebView.java:581)
                                                                  at android.webkit.WebView.<init>(WebView.java:564)
                                                                  at android.webkit.WebView.<init>(WebView.java:551)
                                                                    ... 33 more
  • 写回答

5条回答 默认 最新

  • weixin_39881016 2017-11-23 10:14
    关注

    不是xml问题,是webview在android8.0的问题,你可以看看这个https://support.google.com/work/android/answer/7506908?hl=en

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 工业数据采集技术+存储架构推荐
  • ¥15 GPT-SOVITS如何训练少数民族语言支持合成语音
  • ¥20 树莓派4b使用Camera Module 3时出现the system should be configured for the legacy camera stack问题
  • ¥200 GitHub开源程序配置在VScode调试
  • ¥15 爬虫保存的scv文件0kb
  • ¥20 如何实现基于强化学习的带电作业机械臂的运动规划与控制
  • ¥15 使用wpf制作打砖块游戏时遇到的一个Bug
  • ¥15 qrCodeDetector.detectAndDecode
  • ¥15 海洋可控源和大地电磁一维联合反演
  • ¥15 MFC多文档程序获取视图指针问题