mdoery ~ software development

adventures in coding

where did my GridLayout go?

| Comments

Summary: The class android.support.v7.widget.GridLayout vanished from my Eclipse project! Here’s how I retrieved it.

I was working on an Android project in Eclipse a while back, when I got pulled off of it to do some contract work. When I finally returned to the project today, I was surprised to see it had this compiler error: “The import android.support.v7.widget cannot be resolved”.

Periodically I’m dumbfounded by things which happen in Eclipse, but I’ve begun to take surpises in a stride. I searched around the internet for posts which reported this problem and eventually found that the solution is to import a “support” library which is found in the Android SDK directory. For me, that jar file is located here: C:\Program Files\Android\android-sdk\extras\android\support\v7\gridlayout\libs\android-support-v7-gridlayout.jar

This is a quick rundown of the simple procedure I followed to solve the problem:

  1. Open Eclipse’s Navigator view (from the menu up top, select Window > Show view > Navigator)
  2. Right-click on the project’s libs directory
  3. From the menu which opens, choose “Import…” and then choose “File System”.
  4. In the “File System” dialog which opens, navigate to wherever your android-support-v7-gridlayout.jar has been stored. Like I said above, for me it was under C:\Program Files\Android\android-sdk\extras\android\support\v7\gridlayout\libs\android-support-v7-gridlayout.jar where presumably the Android SDK Manager placed it. Select the jar file, and click the Finish button.
  5. Tada! The compiler error goes away.

I don’t understand how this project broke while I wasn’t working on it. I can only imagine that the imported library was somehow deleted, but I don’t recall doing that, so it’s another one of those fun Android mysteries!

P.S. This evening, I discovered that I had added the jar file to a separate, Android library Eclipse project and had set that project as an Android reference for my current project (under Properties > Android). The library project had been closed some time between now and then. So that explains why the file was “missing;” it was never there to begin with!

Comments