运行时来自 Eclipse 和 android.view.InflateException 的警告

发布于 2024-12-15 11:37:43 字数 1121 浏览 0 评论 0原文

在膨胀布局时,我偶尔会收到用户的异常报告:

android.view.InflateException:二进制 XML 文件第 2 行:膨胀类 com.MyClass 时出错

这种情况很少发生,我自己从未见过......直到现在。突然间,我每次都会遇到这个异常,使用与我一直使用的完全相同的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <com.comet.android.keyboard.CandidateView
        android:id="@+id/candidate"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    </com.comet.android.keyboard.CandidateView>

    <include layout="@layout/keyboard_view" />

</LinearLayout>

此外,Eclipse 总是在第 1 行报告此警告:

未检测到文档的语法约束(DTD 或 XML 架构)。

关于为什么我会在第 1 行收到警告并在第 2 行收到异常,有什么想法吗?两者有关联吗?这个文件直到今天都有效,我没有改变它!

我注意到命名空间 URL http://schemas.android.com/apk/res/android 无法解决。会是这样吗?它与所有 Android 示例中使用的 URL 相同。

I've been getting occasional exception reports from my users when inflating a layout:

android.view.InflateException: Binary XML file line #2: Error inflating class com.MyClass

It happens rarely and I've never seen it myself... until now. Suddenly I get that exception every time, using the exact same layout that I've been using all along:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <com.comet.android.keyboard.CandidateView
        android:id="@+id/candidate"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    </com.comet.android.keyboard.CandidateView>

    <include layout="@layout/keyboard_view" />

</LinearLayout>

In addiation, Eclipse has always reported this warning on line #1:

No grammar constraints (DTD or XML schema) detected for the document.

Any ideas on why I would get a warning on line #1 and an exception on line #2? Are the two related? This file worked until today and I didn't change it!

I've noticed that the namespace URL http://schemas.android.com/apk/res/android doesn't resolve. Could that be it? It is the same URL used in all the Android examples.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

り繁华旳梦境 2024-12-22 11:37:43

该警告是无害的。如果您想摆脱它,请查看此处 http://code.google .com/p/android/issues/detail?id=9831

这个错误很奇怪......你能发布你用来膨胀布局的代码吗?您还有一个名为 com.MyClass 的类吗?

The warning is harmless. If you want to get rid of it look here http://code.google.com/p/android/issues/detail?id=9831

The error is strange... could you post the code you use to inflate the layout? Also do you have a class called com.MyClass?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文