woodglue
woodglue

Reputation: 223

Questions on sample "ActionBarCompat"

I have been struggling with a problem in the past few days. I really appreciate your help!

When I build/run the sample "ActionBarCompat" with target API level 14. Everything works great.

Then I switched to target API level 8(after all, this is meant to be used in old device with old api levels), it looks like without manually commenting out a lot of code that specifically invokes support API level 8 and up(e.g. android.R.id.home, Build.VERSION_CODES.HONEYCOMB), the sample App won't build at all.

Does that mean that an app must have multiple source code versions in order to run in different api levels? Ideally, one set of source code can be used for devices of all API levels.

Thanks in advance!

humblelearner

Upvotes: 1

Views: 960

Answers (1)

KCope
KCope

Reputation: 36

The code that they provided should run on api levels 4 through 15. I can verify that it runs on api 8 and api 15 as I have the same apk running on a Droid Incredible running froyo(2.2) and a Galaxy Nexus running ICS(4.0.3). You can leave the targetsdkversion set to 14.

Make sure you have the support package found in the sdk under /extras/android/support/v4/android-support-v4.jar added to the project. Copy that file to the /libs directory, right-click it and select Build Path > Add to Build Path. Full instructions are at http://developer.android.com/sdk/compatibility-library.html

Upvotes: 2

Related Questions