tags:

views:

101

answers:

2

I want my Android app to have maximum reach, and hence want to support all versions V1.5 onwards. I find some features lacking in V1.5 that are available in V2.0 or V2.1. Could I compile on V2.1, and then set minSDK for the app to run on 1.5?

Plain logic says 2.1 specific features would not work, but let me know your thoughts.

Also, what are some other workarounds? What would "you" normally do in such a situation?

A: 

I would think there are two ways to handle this. In both cases you can develop against the 2.1 SDK and on startup check out what version of Android you're running with. Then you can either swap out whole classes based on the version or you can just block certain calls to methods that don't exist in 1.5.

CaseyB
+1  A: 

This is definitely possible; some of the techniques for backwards compatibility such as reflection and wrapper classes are documented in this article:

Also, I'd recommend compiling against the 1.5 or 1.6 SDK, otherwise you may end up accidentally using classes/methods from later SDKs and running into runtime errors on 1.5 devices due to those APIs not being available.

Roman Nurik