首页 > 解决方案 > android.content.res.Resources$NotFoundException · 字符串资源 ID #

问题描述

我收到此错误:

android.content.res.Resources$NotFoundException · 字符串资源 ID #0x2040003

在整个堆栈中,我看到它取决于:

Resources.java:322android.content.res.Resources.getText

我知道错误可能是我在某个地方调用了一个setText没有传递字符串的地方。

我的问题是我不知道问题出在哪里。
从技术上讲,错误的行是这样的:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return inflater.inflate(R.layout.fragment_web, container, false); // <-- HERE IS THE ERROR
}

布局文件是:

<WebView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".view.WebFragment" />

我不知道如何找到发生错误的行代码。

标签: javaandroidandroid-layout

解决方案


它可能与此问题有关:关于 Webview 的https://issuetracker.google.com/issues/141132133 。

它也发生在我身上,就我而言,它是扩展 Webview 的 MarkdownView。显然升级 android appcompat 库解决了这个问题,但我仍然希望为当前库版本提供另一种解决方案。

因为我在 2 个不同的地方(具有相同的实现)使用了导致崩溃的元素,并且它只在其中 1 个地方崩溃。我一直在花时间搜索这个问题,但仍然不知道为什么以及如何解决它。


推荐阅读