I'm new to Android development, so it's possible this is a simple question. Apologies if it is - I spent quite some time searching but couldn't find anything that worked.
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.
(Screenshot)
From the error log,
android.support.v7.widget.GridLayout failed to instantiate.
Here's the stack trace
My search for this error turned up this SO thread, which seemed promising; I checked my Java, Eclipse and ADT versions but all seem to be reasonably up-to-date (Java 7 update 17, Eclipse Juno release, ADT 21.1). With the update checks out of the way, I looked at how that SO user had his project set up: a library project for the gridlayout, a project reference to this library in the main project, and the gridlayout jar copied into the main project's libs folder. Following the Eclipse "install compatibility library" message, a gridlayout library project had already been created for me, but the project reference had not been set up and the gridlayout jar hadn't been copied. I did both these things but still the GridLayout fails to instantiate.
I continued searching and found another SO thread. Despite that thread not using Eclipse, I attempted to translate the answer into the Eclipse equivalent, which was roughly the same as given by the thread above. (Copy the gridlayout jar to the project's libs folder, create a library project from gridlayout, and add a project reference to that library project from within the main project.) I also verified that the gridlayout jar is on the main project's build path. (Screenshot)
I also attempted to follow the instructions in the relevant Styling Android blogpost, but that's even worse: when I try to drag a GridLayout into my project, it throws two errors, a RelativeLayoutRule.onDropped() failed:
java.lang.NullPointerException
with this stack trace and an Initializing project state
with this stack trace. Based on the IOException mentioned in the "Initializing project state" stack trace, I speculated the problem might be my install location for the Android SDK: %APPDATA%\Local\Android
. I finally tried uninstalling the SDK and reinstalling it to %PROGRAMFILES%\Android
but without any luck.
I'm not really sure where to go from here. If anyone could give me a pointer in the right direction, I'd really appreciate it!