"android.v4.widget.SlidingPaneLayout class could not be found" 异常

"android.v4.widget.SlidingPaneLayout class could not be found" exception

我正在开发一个 android 应用程序,我想使用 SlidingPaneLayout。我的 activity_main.xml 是:

<?xml version="1.0" encoding="utf-8"?>

<android.v4.widget.SlidingPaneLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" tools:context="absolute.beginners.hellouniverse.MainActivity" 
    android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/spLayout" >

    <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content">    
        <TextView android:text="@string/name" />        
    </LinearLayout>

</android.v4.widget.SlidingPaneLayout>

这个 xml 在 xml 编辑器中没有给出任何错误。当我尝试查看图形布局时,我不断收到此错误:

Exception raised during rendering: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
Exception details are logged in Window > Show View > Error Log
The following classes could not be found:
- android.v4.widget.SlidingPaneLayout (Fix Build Path, Edit XML, Create Class)

我在AndroidManifest.xml中使用的sdk是:

<uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />

我在 windows 8 机器上使用 Eclipse IDE Luna Release 2 (4.4.2),并且 android-sdk 和支持库是最新的版本。

我搜索了Whosebug,发现了很多关于这种错误的答案。我已经尝试了一切:在 libs 文件夹中添加 android-support-v4.jar 文件,将该文件添加到构建路径中的 "order and export" 选项卡,重新启动 Eclipse,一次又一次地清理项目,但是我没有办法。

任何人都可以帮我解决这个例外吗?

更新: 当我 运行 应用程序时,模拟器正在打开并且我的程序崩溃了。错误信息是:

03-31 02:13:48.870: E/AndroidRuntime(1129): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.v4.widget.SlidingPaneLayout
03-31 02:13:48.870: E/AndroidRuntime(1129):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
03-31 02:13:48.870: E/AndroidRuntime(1129):     at android.view.LayoutInflater.inflate(LayoutInflater.java:469)

当然不能。 SlidingPaneLayout的全名应该是android.support.v4.widget.SlidingPaneLayout而不是android.v4.widget.SlidingPaneLayout