0

I found a lot of online resources regarding targeting a variety of Android versions from my min-SDK version up through my target-SDK. This includes doing things like reflection or wrapper classes to test for the advanced functionality that may be available only in the higher Android version I'm targeting.

What I cannot figure out is how to get this to work in Eclipse. Specifically, the problem I am running into is that if I choose a Project Build Target that matches my target-SDK then Eclipse will not allow me to select an AVD with a lesser Android version for debugging/testing. Therefore I can't test the reflection tricks to make sure they work for backwards compatibility. The alternative of choosing the lowest Project Build Target means that I cannot refer to any of the advanced classes/methods available only in the newest Android versions without getting compiler errors.

What is the correct way to organize an Eclipse Android project to make targeting multiple versions work?

(P.S. I'm trying to use the old, undocumented calendar access tricks alongside the new ICS calendar API.)

Thanks!

Darshan Rivka Whittle
  • 32,989
  • 7
  • 91
  • 109
DiZiGeL
  • 3
  • 1

1 Answers1

0

project.properties includes your build target. set this to android-15 (latest API). In the manifest set min-sdk to the minimum sdk you are supporting for example 8 (froyo). This is the minimum API and it will only launch on devices with API bigger or equal than this.

Make sure you test all API's which are lower than the target as some methods might not work. An example for this is the ActionBar introduced in Honeycomb - it will not work on API's lower than Honeycomb.

paulgavrikov
  • 1,883
  • 3
  • 29
  • 51
  • Thank you, this works. I must have had an unrelated problem because I had that configuration but rechecked things along with Android_Tools->Fix_Project_Properties and now all the AVDs are appearing. I'm not sure what was messed up but at least you have confirmed the right way to set up the project. :-) – DiZiGeL May 23 '12 at 21:06
  • Alas, I closed Eclipse and when I re-opened later the AVDs that aren't android-15 are all hidden from me again. Quite annoying. – DiZiGeL May 25 '12 at 13:40
  • Figured it out. If you have Project.Properties.run/debug_settings.Target.Deployment_Target_Selection_Mode set to "manual" AND have a device plugged in, then you will only see a choice of the device or AVDs that match the target-SDK. If you unplug the device, you will see all your AVDs when you attempt to run your code. – DiZiGeL May 25 '12 at 13:47