4

我正在尝试在我的 Android 2.2 项目中使用 GridLayout,在我的工作区中安装了 gridlayout_v7 项目后,将其添加到我的项目 Android 依赖项中,为其自定义属性添加自定义 xmlns,并将其嵌入到我的 xml 布局中:

<android.support.v7.widget.GridLayout
    android:layout_width="match_parent"
    android:layout_height="300dp"
    grid:columnCount="2"
    grid:rowCount="3" >

    <include
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        layout="@layout/quick_contact" />
    <include
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        layout="@layout/quick_contact" />
    <include
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        layout="@layout/quick_contact" />
    <include
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        layout="@layout/quick_contact" />
    <include
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        layout="@layout/quick_contact" />
    <include
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        layout="@layout/quick_contact" />
</android.support.v7.widget.GridLayout>

我在运行时开始收到以下异常:

java.lang.ClassNotFoundException: Didn't find class 
"android.support.v7.widget.GridLayout" on path: DexPathList[[zip file 
"system/framework/android.test.runner.jar", zip file "data/app/<app package>.apk"], 
nativeLibraryDirectories=[data/app-lib/<app package>, /vendor/lib, /system/lib]]

我尝试过清理和重建,删除库并再次添加,但无济于事。关于可能导致这种情况的任何想法?

4

1 回答 1

1

I saw this error. For me, I had to include grid layout specifically in my dependencies like so:

dependencies {
   ...
   compile 'com.android.support:gridlayout-v7:18.0.+'
}

See more here about how to include support libraries: https://developer.android.com/tools/support-library/features.html

于 2014-08-05T19:52:50.737 回答