So this was happening because the android-support-v4 library that my project was referring to was older than the latest available. Since we have to copy android-support-v4.jar library manually into our project's /libs folder, no matter how many times you update the sdk, it will have little impact until we manually overwrite support library .jar thats there in the project folder.
Where I went wrong? I was under the impression that I have the latest android-support-v4.jar in my project directory. Since all my attempts to solve this issue by changing the build path and order failed, as a final resort I overwritted my android-support-v4.jar in the project /libs with one in the /extras/android/support/v4/android-support-v4.jar. Voila it started working.
And this is how I added support-v7 gridlayout into my project
- Copy 'gridlayout' folder from '\extras\android\support\v7' to location where your android project is located
- Import the library copied in step1 as android-library into workspace
- Reference the imported library from step2 on your android application
Note:
- After the above steps are performed check 'android-support-v7-gridlayour.jar' is included under 'Android Dependencies' under your android application project.
Check a new line is added for 'gridlayout' project in your android application's 'project.properties'. In my case the below line was added
android.library.reference.1=../gridlayout
Apart from the above mentioned steps I did not follow any other steps mentioned here