Can I compile an Android App on 2.1 and have support for all versions 1.5 onwards?

痴心易碎 提交于 2019-12-24 00:19:03

问题


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?


回答1:


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

  • Backwards Compatibility for Applications

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.




回答2:


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.



来源:https://stackoverflow.com/questions/2768101/can-i-compile-an-android-app-on-2-1-and-have-support-for-all-versions-1-5-onward

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!