Pregunta

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?

¿Fue útil?

Solución

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.

Otros consejos

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).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top