2011-11-11 71 views
1

充气布局的时候我已经从我的用户越来越偶有例外报告:从Eclipse和android.view.InflateException警告在运行时

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> 

在addiation,Eclipse已经老是报1线#这样的警告:

无为文档检测到的语法约束(DTD或XML模式)。

为什么我会在第1行发出警告,第2行发生异常?这两个有关系吗?这个文件一直工作到今天,我没有改变!

我注意到名称空间的URL http://schemas.android.com/apk/res/android没有解决。这可能吗?这是所有Android示例中使用的相同URL。

回答

1

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

错误是奇怪的......你可以发布你用来膨胀布局的代码?你也有类叫com.MyClass

+0

在完全清理完所有项目并重新安装应用程序后,该错误消失。不过,我一直在从同一个例外的领域得到报告。这是膨胀上面的布局的行:mKeyboardLayout =(View)getLayoutInflater()。inflate(R.layout.keyboard_layout,null); 这很简单。 “com.MyClass”应该是实际类名的占位符,但这是我的错误。例外只是说“...错误膨胀类”,并没有提及任何类名。 –