Khawaja Absar Khawaja Absar - 6 months ago 53
Android Question

android.support.v7.widget.GridLayout failed to instantiate

I'm trying to use a

GridLayout
in my project, but ideally with the Android Support Library so I can target lower versions of the API. When I drag a
GridLayout
into the graphical layout designer, a message pops up asking explaining I need a compatibility library for API versions older than 14, and asks if I want to install this library. I hit "Install" and let Eclipse do its thing, but an error shows up in the Eclipse graphical layout designer:

The following classes could not be instantiated: - android.support.v7.widget.GridLayout See the Error Log ( Window > Show View) for more details."


(here is screenshot )

From the error log,
android.support.v7.widget.GridLayout
failed to instantiate.

Answer

Make sure you have added the GridLayout library project in your project as library.

Try out as below to import the library project of GridLayout

File->Import->Existing Android code into workspace Specify android-sdk-[path]/extras/android/support/v7/gridlayout

Make sure You import and copy the GridLayout project as an Android library project into your workspace.

After import library project add it into your project as library as below:

Right click your Project->Properties->Java Build Path->Order and Export where tick mark all option.