1

When I create a new Android Sample Project from eclipse with api level 14, add the compatibility library and try to run it on my gingerbread device. It gave the following error :

Error Inflating Class SwitchPreference 

I just commented the SwitchPreference from the preferences xml file and was able to run the api demos app. But the Fragment(and few others) demos were not available.

Is this expected? should I have a device running api-14 to be able to see the Fragment demos? Am I missing anything in the process of creating the project?

Any help is appreciated.

500865
  • 6,920
  • 7
  • 44
  • 87

2 Answers2

4

The compatibility library provides the Fragment API, but it doesn't somehow upgrade your API level 10 device to API 11 or 14. The sample projects for API 14 probably use other APIs besides fragments that the compatibility library does not provide. Additionally, the namespaces are different. You'll have to do some work to port that sample back if you want to run it on Gingerbread. I would look in the samples in the compatibility library instead.

kabuko
  • 36,028
  • 10
  • 80
  • 93
  • Much better explanation than my attempt :-) – ahodder Nov 18 '11 at 21:56
  • hmmm.. I tried to change the targetSdk to 8.. Eclipse doesn't replace the Android 4.0 jar with Android 2.2 jar... But I dint know that there were samples for the compatibility library too.. That link helped.. Thanks.. – 500865 Nov 18 '11 at 22:34
1

API 13 devices can't run API 14 programs. Drop the required API level of your application (if you can). If you're not using any API 14 things, it should work for you.

ahodder
  • 11,353
  • 14
  • 71
  • 114