On Mon, Jan 2, 2012 at 4:54 AM, senglund <[email protected]> wrote:
> Sorry if this is obvoius but I am quite new to android development. I
> am currently trying to learn about using fragments and using fragments
> for different screen sizes and screen orientations.
>
> So, I intend learn about and use the Android Compatibility Package.
> With that comes a sample, "Support4Demos", which I import to my
> Eclipse workspace.  If I set project build target to API level 15
> (4.0.3) everything looks fine, but if I set build taget to something
> like API level 10 (2.3.3) Eclipse will report an error for one of the
> files.

Of course. You set your build target to be the lowest level of the
capabilities that you are using explicitly. Setting it lower than that
will result in compile errors, by definition.

> The file is styles.xml under directory values-v11 and one of the
> errors are reported for the following:
>
>    <!-- For API level 11 or later, the Holo theme is available and we
> prefer that. -->
>    <style name="ThemeHolo" parent="android:Theme.Holo">
>    </style>
>
> The comment indicates that this should be used for API level 11 or
> later. But if it does not compile what is the file doing in a sample
> for a compatibility package supposed to be used for API levels earlier
> than API level 11. This leads me to think that I do something wrong
> with my project setup.

Set your build target to API Level 11. The resulting app can still run
on earlier versions of Android.

> If I intend to have my app be compatible for all versions from 2.3.3
> and later should I not set project build target to API level 10
> (2.3.3) ( and correspondingly the min sdk attribute)?

Not necessarily. You set your build target to be the lowest level of
the capabilities that you are using explicitly.

> Or can it be OK
> to set project build taget to the latest API level and still use it on
> earlier builds?

Yes. What you lose is compile-time sanity checks. For example, if your
reference to Theme.Holo was in res/values/, not res/values-v11/, that
will cause a problem on API Level 10 (and lower) devices. With the
build target set to API Level 10, you would catch this at compile
time; with a build target of API Level 11 or higher, you would catch
this at runtime when testing your app on the older device.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android 4.0 Programming Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to