简体   繁体   中英

GridLayout compatibility - ClassNotFoundException: Didn't find class “android.support.v7.widget.GridLayout”

I'm trying to use GridLayout in my Android 2.2 project, and after having installed the gridlayout_v7 project in my workspace, adding it to my projects Android Dependencies, adding a custom xmlns for its custom attributes, and embedding it in my xml layout as such:

<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>

I started getting the following exception at runtime:

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]]

I have tried cleaning and rebuilding, removing the library and adding it again but to no avail. Any ideas as to what may be causing this?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM