2

I want to use Grid Layout, but get the following error:

Error: No resource identifier found for attribute 'columnCount' in package 'android'

Is this because my API level is 9?

Does Grid Layout REALLY need API level 14? (I use Version: 8.0.1.v201012062107-82219)

  • If yes, what should I do? Please explain this step by step.
  • If no, so what's the reason? I'm doing exactly the same as the example!
Jeroen
  • 60,696
  • 40
  • 206
  • 339
Soroor
  • 109
  • 2
  • 7
  • Have a look at this link: http://developer.android.com/reference/android/widget/GridLayout.html#getColumnCount%28%29 It says API 14. – Bruno Bieri Sep 21 '12 at 14:33
  • This is API Level 14 according to the docs yes. You either need to increase your min-target-SDK. Or use another approach. It could potentially work with the google compatibility thing. – IAmGroot Sep 21 '12 at 14:34
  • could you please guide me how to increase my min-target-SDK? because i don't want use another approach.. – Soroor Sep 21 '12 at 14:52
  • thanks viperbone & Doomsknight, But i CAN'T visit [link](http://developer.android.com). because we're boycotted. – Soroor Sep 21 '12 at 14:56

4 Answers4

2

Here are the steps i spent to solve my problem:

To use GridLayout, i figured out many things should be upgraded.

  1. i had "jdk 7" installed on my system, so didn't need to upgrade it.
  2. i downloaded "installer_r20-windows.exe" and ran it.
  3. i downloaded "platforms" which contains "android-14", and copied it into android-sdk folder. (mine is: C:\ Android\android-sdk)
  4. i downloaded "system images" which contains "armeabi-v7a", and copied it into my sdk folder.
  5. i downloaded "platform-tools_r13-windows" and copied it into SDK folder.
  6. Then i found out also my eclipse is old, thus downloaded it's latest version, "eclipse 4.2_juno" (27 june 2012)
  7. i downloaded "Eclipse-plugins-ADT-20.0.zip". Then into eclipse: Help > Install New Software > Add > Archive > Eclipse-plugins-ADT-20.0.zip. Then select "Developer Tools" > click next > accept > click finish > restart eclipse.
  8. Again in eclipse: Window> Preferences > Android > SDK Location: path where my android-sdk folder exists.(e.g. mine is "C:\Android\android-sdk") > Apply > select "Android 4.0" > click OK.
  9. Then i created new AVD, from: eclipse > Window > AVD Manager > New..
  10. Finally, into sdk folder i created a new folder named "extras", into it another new folder named "android", into it another new folder named "support".
  11. Then i extracted content of "support_r09.zip" (which have downloaded it).

Now everything is ok..

Thanks to everybody helped me in this post (viperbone, Doomsknight, Matthieu, MemLeak,Jeroen).

Soroor
  • 109
  • 2
  • 7
1

Yes, the GridLayout is only available if you run it on devices with API Level 14 or higher.

Not sure what that version 8.0.1.... is ? Definitely not the Android version.

If you plan to run your application on anything earlier than Ice Cream Sandwich I am afraid you have to use something else than that Layout. TableLayout maybe ? Or check this question

MORE (from comments):

Either you are ok with your app to run only on ICS or above (so somebody with a phone with Gingerbread will not be able to run it for example).

If yes, then:

  • Download the latest Android SDK
  • Set targetSDKversion="14" in your manifest

And this error should go away.

If no, then you CANNOT use GridLayout. You have a few options to replace it:

Community
  • 1
  • 1
Matthieu
  • 16,103
  • 10
  • 59
  • 86
  • Hi Matthieu. OK, to be more clear i use Android 2.3 (API level:9). – Soroor Sep 21 '12 at 14:39
  • Then either you use that custom library that is linked from github or you have to use something else (TableLayout, construction of LinearLayouts...) – Matthieu Sep 21 '12 at 14:41
  • And i'm writing a game program "on my LAPTOP" using emulator. PLEASE TELL me what should i do? Is there anyway to upgrade? – Soroor Sep 21 '12 at 14:41
  • What do you mean? " you use that custom library that is linked from github"?? – Soroor Sep 21 '12 at 14:42
  • the question is really what you want to app to run on... if it's ok to run only on ICS, then make sure you download the latest SDK and change your AndroidManifest to have targetSDKversion="14" then you are able to use the GridLayout – Matthieu Sep 21 '12 at 14:43
  • i HAVE TO use grid layout. do you have any sample of it? – Soroor Sep 21 '12 at 14:43
  • i've added – Soroor Sep 21 '12 at 14:45
  • Make sure you have the latest SDK installed on your computer too – Matthieu Sep 21 '12 at 14:47
  • Matthieu, did you know that there is a package called support-library-v7? This one will provide the GridLayout to older API Levels. – Phantômaxx Jun 15 '14 at 10:14
  • @DerGolem I did not know that... maybe I missed it or it was not available when I wrote this. – Matthieu Jun 15 '14 at 21:07
1

GridLayout needs API 14

You can create a Layout for the other android versions -> Adapt layout to Android platform or API level

Community
  • 1
  • 1
MemLeak
  • 4,456
  • 4
  • 45
  • 84
0

In your manifest use:

<uses-sdk minSdkVersion="14" />

However, this will mean that any device running an Android API below 14 will not be able to use your app

fat
  • 6,435
  • 5
  • 44
  • 70