I am getting back to work on an app I worked on a while ago, when I had everything built around Android 2.2 Froyo.
I have updated my SDK for the latest APIs and noticed that the ClipboardManager features I was using are deprecated. I updated the code to use the newer ClipData model and tried it out on my Froyo phone and, of course, I get a NoClassDefFoundError in the new code.
I've had a look around SO and haven't found any real discussions of general strategy for maintaining backwards compatibility.
I'm not entirely sure how I should handle this and other situations where the API differs, because I want users of all versions to be able to use my app.
Should I be doing a check as follows?
if(version == old){
use old API;
} else {
use new API;
}
If so, I have deprecated code in my class and Eclipse will have the warning there forever.
On the other hand, I could just build against an old version of the API and hope that new versions will handle it okay. But then I run the risk of building against buggy or low-performance code when a better alternative is available.
What is the best way to deal with this?