【问题标题】:Warning from Eclipse and android.view.InflateException at runtime运行时来自 Eclipse 和 android.view.InflateException 的警告
【发布时间】:2011-11-11 21:33:47
【问题描述】:

我在扩展布局时偶尔会收到用户的异常报告:

android.view.InflateException: Binary XML file line #2: Error inflating class 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 相同。

【问题讨论】:

    标签: android android-layout android-xml


    【解决方案1】:

    警告是无害的。如果你想摆脱它,请看这里http://code.google.com/p/android/issues/detail?id=9831

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

    【讨论】:

    • 在我彻底清理所有项目并从头开始重新安装应用程序后,错误消失了。但是,我一直在收到来自同一异常领域的报告。这是使上面的布局膨胀的行: mKeyboardLayout = (View)getLayoutInflater().inflate(R.layout.keyboard_layout, null);这很简单。 “com.MyClass”应该是实际类名的占位符,但这是我的错误。异常只是说“......错误膨胀类”并且没有提到任何类名。
    猜你喜欢
    • 1970-01-01
    • 2019-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多