Changing the Build Path
To change the build path for an app (useful for debugging and being sure it will run on all target platforms):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lightcone.recipes"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="3" />
<uses-library android:name="com.google.android.maps" />
.
.
.
</manifest>
we have selected a build against Android 1.6 (which is API level 4), but we are specifying through the android:minSdkVersion attribute that it should also run under Android 1.5 (which is API level 3). Thus, for example, this program is compiled for Android 1.6, but the resulting .apk project file installs and executes on a Motorola Backflip phone running Android 1.5 (because of the android:minSdkVersion="3" attribute, and because it does not use any API commands that were not available under Android 1.5), and also runs under an Android 2.2 emulator because of backward compatibility.
If, on the other hand, we change to android:minSdkVersion="4" in the AndroidManifest.xml file, we will get the following error message if we try to launch the application on the Backflip phone running Android 1.5 over the USB connection:
[2010-06-07 16:56:38 - Recipes] ERROR: Application requires API version 4. Device API version is 3 (Android 1.5).
[2010-06-07 16:56:38 - Recipes] Launch canceled!
(If an app with this manifest restriction were placed in the Android Market, it would be filtered out of the displayed list of available apps and never even be seen by the user unless the phone accessing the Market runs Android 1.6 or later.) Even though in this case the program will actually run under Android 1.5, we have used the manifest file to allow it to be installed only if the phone is running Android 1.6 or later. This illustrates how the android:minSdkVersion attribute allows us to control which versions of the operating system the program is allowed to run under.