最近线上后台发现一个崩溃问题,在Android5.x上,创建webview时会发生carsh,报错信息:

Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2040003

at android.content.res.Resources.getText(Resources.java:318)

at android.content.res.VivoResources.getText(VivoResources.java:123)

at android.content.res.Resources.getString(Resources.java:404)

at com.android.org.chromium.content.browser.ContentViewCore.setContainerView(ContentViewCore.java:694)

at com.android.org.chromium.content.browser.ContentViewCore.initialize(ContentViewCore.java:618)

at com.android.org.chromium.android_webview.AwContents.createAndInitializeContentViewCore(AwContents.java:631)

at com.android.org.chromium.android_webview.AwContents.setNewAwContents(AwContents.java:780)

at com.android.org.chromium.android_webview.AwContents.(AwContents.java:619)

at com.android.org.chromium.android_webview.AwContents.(AwContents.java:556)

at com.android.webview.chromium.WebViewChromium.initForReal(WebViewChromium.java:312)

at com.android.webview.chromium.WebViewChromium.access$100(WebViewChromium.java:96)

at com.android.webview.chromium.WebViewChromium$1.run(WebViewChromium.java:264)

在大部分的vivo 5.x系统下会出现问题,非5.x系统不会出现。

解决办法一

在Android5.x上通过解决自定义WebView

网上大部分都是这种方式解决的。

public class LollipopFixedWebView extends WebView {

public LollipopFixedWebView(Context context) {

super(getFixedContext(context));

}

public LollipopFixedWebView(Context context, AttributeSet attrs) {

super(getFixedContext(context), attrs);

}

public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr) {

super(getFixedContext(context), attrs, defStyleAttr);

}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)

public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {

super(getFixedContext(context), attrs, defStyleAttr, defStyleRes);

}

public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr, boolean privateBrowsing) {

super(getFixedContext(context), attrs, defStyleAttr, privateBrowsing);

}

public static Context getFixedContext(Context context) {

if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT < 23) // Android Lollipop 5.0 & 5.1

return context.createConfigurationContext(new Configuration());

return context;

}

}

主要核心方法是getFixedContext(context),根据版本号配置不同的context.

解决方法二

如果项目中使用"androidx.appcompat:appcompat:1.1.0" ,替换为"androidx.appcompat:appcompat:1.0.2"

1.1.0版本webview在Android5.x上有问题,恢复到1.0.2之后确实解决了此问题,目前没有具体追踪,后续会跟上。

"androidx.appcompat:appcompat:1.1.0"发布时间:2019/09/05,到现在更新一个月时间~

"androidx.appcompat:appcompat:1.0.2"发布时间:2018/10/07,到现在更新一年时间~

为了保证项目稳定,build gradle依赖更新时间要适当。

最后,希望此篇博客对大家有所帮助,欢迎提出问题及建议共同探讨,如有兴趣可以关注我的博客,谢谢!

android webview 报错,Android WebView 5.x 系统下 Resources$NotFoundException异常处理相关推荐

  1. android override报错,android @override 报错解决方案

    android @override 报错解决方案 现象: ... java: 1801: method does not override a method from its superclass @ ...

  2. android 编译报错,android avc 编译报错neverallow问题查找

    android avc 编译报错neverallow问题查找 2020年08月11日 | 萬仟网移动技术 | 我要评论 在修改avc后,有时候编译会报错neverallow.这个具体是在什么地方定义的 ...

  3. android 打包报错,android 打包报错,请问有没有好的解决办法

    #1.基本指令区 #-optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontsk ...

  4. android edittext报错,Android中editText使用报错

    在activity_main.xml文件中添加了editText控件 android:id="@+id/edit_text" android:hint="@the nex ...

  5. android 签名报错,Android系统签名报错 no conscrypt_openjdk_jni in java.library.path

    1.Android 7.1之前,系统签名如下: java -jar signapk.jar platform.x509.pem platform.pk8 source.apk target.apk 2 ...

  6. Android Studio报错Android resource linking failed mergeDebugResources-24:/values-v31/val...的解决方案

    检查你的sdk库是否包括Android12(API31),错误原因是缺少v31的资源文件,勾选并下载API31的sdk即可.

  7. Android各种报错问题汇总

    一.Android调试中报错:Could not connect to remote process. Aborting debug session. 在AndroidManifext.xml中的添加 ...

  8. 打开Android Studio报错required plugin “Android Support” is disabled

    打开Android Studio报错 Plugin Error: required plugin "Android Support" is disabled 更详细的错误信息如下: ...

  9. the android emulator process,Android studio报错:The emulator process for AVD (xxx) was killed

    背景:重做系统后重新配置Android studio 安装虚拟机后无法启动 log中显示为启动AVD的进程被杀 控制台显示为:在虚拟机列表里没有找到所要启动的AVD的名称 首先考虑是BIOS问题:发现 ...

最新文章

  1. python公共操作(运算符(+、*、in、not in)、公共方法(len()、del、max()、min()、range()、enumerate())、类型转换(tuple、list、set))
  2. Day2_CSS_CSS语法及HTML结合
  3. 作为程序员我给csdn博客添加打赏功能
  4. 如何用html绘制阴影图形,HTML5 给图形绘制阴影
  5. Mybatis源码解析之Mybatis初始化过程
  6. Python爬虫基本库的使用
  7. 五分钟没有操作自动退出_消防设施操作员 精选练习题10.31
  8. Yann LeCun提出首个多模态高性能自监督算法,语音、图像文本全部SOTA
  9. greenev —— Python 异步网络服务框架
  10. 汽车VIN码超详细解析规则
  11. C语言正则表达式详解 regcomp() regexec() regfree()详解
  12. win10无法启动修复服务器,win10 bcd损坏无法开机怎样修复_win10系统bcd损坏开机进不了系统解决方法...
  13. 【原创】聊天机器人与自动问答技术
  14. 试编程判断输入的正整数是否既是5又是7的整数倍,若是输出“YES“,否则输出“NO“。
  15. mysql-8.0.28-winx64安装步骤
  16. 搭建Bitbucket项目管理工具详细教程
  17. 恢复通讯录显示服务器开小差,手机通讯录误删除怎么恢复?教你几招一看就会...
  18. 接触角测量案例分享及问题解答(一)
  19. 一键制作生日快乐的网站_生日快乐和一本新书
  20. ISO26262解析(一)——概述

热门文章

  1. mysql之慢日志查询
  2. scrapy的post登录:renren
  3. php excel 读取日期问题
  4. (转)NSString to string(支持中文)
  5. HDU3474 Necklace
  6. 线程安全的signals
  7. 数据库 分库 分表 分区
  8. python raise 引起的异常
  9. beego1---beego,bee环境配置
  10. 算法族的集中管理——策略模式