0

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?

slhck
  • 36,575
  • 28
  • 148
  • 201
Gaurav
  • 1,700
  • 4
  • 22
  • 38

2 Answers2

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

Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111
  • I have downloaded google iosched project which is targeted for api level 11. I t runs perfectly on android 2.2(api level 8). – Gaurav May 24 '11 at 12:04
  • Well, if it works: fine. If not: You know where to look for it. Always try to target the lowest Android Version possible (Should be 2.2 or 2.1 by now). – Lukas Knuth May 24 '11 at 12:09
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.

Dave
  • 6,064
  • 4
  • 31
  • 38