i'm developing an android application and i don't know how to make it compatible with all the versions. In eclipse i select only one API level, and in androidManifest i tried to put minSdk and MaxSdk covering all the version, but it crashes on some OS with different version. How can i make it compatible with all the versions? Can you help me?
2 Answers
Do you really need to support all versions? Check out this chart, which the Android team updates monthly, and tells you what percentage of devices are running which Android versions. As you can see, 97% of devices are on Android 2.1+
I recommend supporting only Android 2.1+ (API level 7) if you can.

- 19,192
- 5
- 36
- 77
-
if i use API level 7 ( 2.1 ) it will run also with the higher versions? – Jayyrus Sep 23 '11 at 08:25
-
As for as I know: Yes. An article on this subject: http://developer.android.com/resources/articles/future-proofing.html – Sky Kelsey Sep 23 '11 at 08:32
-
The problem is that package android.media.audiofx in not found in these api level :( – Jayyrus Sep 23 '11 at 08:55
-
@JacopoTurchi, you've nailed the problem yourself. If you need that package, you are talking Android 2.3+, which is only 30% of the install base. Can you use a 3rd party library instead? – Sky Kelsey Sep 23 '11 at 09:05
-
why not, but i don't know where to find it! :) I develop much in java, but is the first application in android! :) – Jayyrus Sep 23 '11 at 09:08
I'd say that you'll make life really hard for yourself by attempting to make your application work on antiquated Android versions (and by that I mean 1.5 and 1.6). As Sky mentioned, only target Android 2.1 and above.
Can you please specify what exception is being thrown when you attempt to run the application on a different version of the OS?
Here's my application's definition in the manifest.
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="10">
Defining it that way does not guarantee that your application will work on Froyo, Gingerbread and Gingerbread_MR1. Here's an example, I can't use requestSingleUpdate() from the LocationManager class in my application because it was only added in API level 9 (and I intend my application to work in API level 8!).
You need to ensure that you use functionality that is in API level 8 and below. Does that make sense?

- 3,239
- 6
- 31
- 40
-
ok, understood! but i don't know how to do the same in all the versions. Example: if i want to use android.media.audiofx, in level api 7 and higher it doesn't work.. – Jayyrus Sep 23 '11 at 09:04
-
As Sky mentioned, a third party library is the obvious solution. However, I've had a quick look and there are no real alternatives for android.media.audiofx from what I could find. – thegreendroid Sep 23 '11 at 10:43
-
-
Yes you can, have a look at [Build.Version](http://developer.android.com/reference/android/os/Build.VERSION.html) and [this question](http://stackoverflow.com/questions/3993924/android-api-level) – thegreendroid Sep 23 '11 at 23:22
-
do u know solution about my problem? what can i do? i want to use visualizer class that is defined only since api level 9 :( – Jayyrus Sep 24 '11 at 20:14
-
Like I said, I couldn't find an equivalent third party library replacement for android.media.audiofx. I am afraid you'll have to make to do without that feature on your application on older phones (< API level 9). Your best bet is to check version dynamically and disable that feature if API level < 9. – thegreendroid Sep 26 '11 at 01:21
-
My problem is to load library like audiofx in a dynamic way.. if i check version on runtime, i make two different way: if(version<=9) setup1(); else setup2(); in setup2 i don't load library, but i call object like visualizer directly from package ( android.media.audiofx.Visualizer vis = new android.media.audiofx.Visualizer(); ) but when this app runs on a device which has api level <9 is crashes, i think cause it compile that code too, but package isn't founded.. true? what can i do? thanks a lot – Jayyrus Sep 27 '11 at 13:50
-
You simply can't use this library on lower versions of Android. How many more times should we mention this? Let me state again: YOU CAN NOT USE android.media.audiofx ON ANDROID 2.2 AND BELOW. – Sky Kelsey Sep 28 '11 at 19:18