Run app with higher SDK on lower SDK

。_饼干妹妹 提交于 2019-12-11 16:55:29

问题


I wanted to know whether an app developed in Android 3.0 runs on Android 2.1. If so, how can I do that?

If I develop the app using the libraries from 3.0 such as fragments, will it work in 2.1?


回答1:


It is possible to write an app targeted for 3.0 that also runs under 2.1. However, it requires careful use of libraries and the Compatibility library.

The first step is to set appropriate android:minSdkVersion and android:targetSdkVersion values in your manifest file. This will define which range of devices will allow your app to run.

The second is to ensure you do not use any API functions from later SDKs on platforms with lower versions - attempts (such as trying to use ActionBar on a 2.2 device) will cause your app to crash.

I'd strongly recommend reading Reto Meier's articles on maintaining backwards compatibility: http://blog.radioactiveyak.com/2011/01/how-to-use-gyroscope-api-and-remain.html http://blog.radioactiveyak.com/2011/02/strategies-for-honeycomb-and-backwards.html

In addition, the source for Googles I/O app is definitely worth examining to see how they handle running on a wide range of devices, whilst still utilising features of Honeycomb (and later) releases.




回答2:


No. But a 2.1 App will run under 3.0

You can try to copy your code and use it with the 2.1 library, but some things won't work (you'll need to do some extra work to port it back).



来源:https://stackoverflow.com/questions/6109980/run-app-with-higher-sdk-on-lower-sdk

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