2

Using this page, http://developer.android.com/sdk/compatibility-library.html , I have installed the Android Support Package, added a libs folder in my project, moved the JAR file into my libs directory, and clicked 'Add to Build Path' but I am still getting the error :

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:
- GridLayout (Fix Build Path, Edit XML)

Here is my XML file...

<?xml version="1.0" encoding="UTF-8"?>
<GridLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:columnCount="2"
    android:rowCount="13" >

    <TextView
        android:layout_gravity="fill_horizontal"
        android:text="SN : " />

    <TextView
        android:id="@+id/snTextView"
        android:layout_gravity="fill_horizontal" />


    <TextView
        android:layout_gravity="fill_horizontal"
        android:text="Ver : " />

    <TextView
        android:id="@+id/verTextView"
        android:layout_gravity="fill_horizontal" />

    <TextView
        android:layout_gravity="fill_horizontal"
        android:text="Type : " />

    <TextView
        android:id="@+id/typeTextView"
        android:layout_gravity="fill_horizontal" />

    <TextView
        android:layout_gravity="fill_horizontal"
        android:text="OD : " />

    <TextView
        android:id="@+id/odTextView"
        android:layout_gravity="fill_horizontal" />

    <TextView
        android:text="Closing Mode"
        android:layout_gravity="fill_horizontal" />

    <TextView
        android:id="@+id/closingModeTextView"
        android:layout_gravity="fill_horizontal" />

    <TextView
        android:text="CT : "
        android:layout_gravity="fill_horizontal" />

</GridLayout>
JuiCe
  • 4,132
  • 16
  • 68
  • 119
  • According to [this answer](http://stackoverflow.com/a/10457249/658042) you have to use the support lib as a library project instead of a jar when you want to use GridLayout. Didn't test this myself though. –  Jun 21 '12 at 13:24

1 Answers1

1

GridLayout is only available in the most recent release compatibility package. You won't be able to use GridLayout for your project unless your minSdkVersion is set to 7 or above.

Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
  • Are you sure about that? I've heard elsewhere that I can...And the .jar file that I downloaded is called andoird-support-v7-gridlayout.jar – JuiCe Jun 21 '12 at 13:25
  • 1
    Oops, you might be right. Last time I checked this wasn't possible... but it looks like they added support for it in revision 8. (I think). What is your `minSdkVersion`? – Alex Lockwood Jun 21 '12 at 13:29
  • 1
    Try using the full tag `android.support.v7.widget.GridLayout` instead of just `GridLayout` in your xml. – Alex Lockwood Jun 21 '12 at 13:33
  • 1
    Also, are you positive that you are using revision 8, not revision 7? – Alex Lockwood Jun 21 '12 at 13:35
  • That didn't work....but yes I just downloaded it from the SDK about 30 minutes ago, it says revision 8. – JuiCe Jun 21 '12 at 13:38
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/12862/discussion-between-user1435712-and-alex-lockwood) – JuiCe Jun 21 '12 at 13:58