Search code examples
androidcompatibilityandroid-manifest

Multiple AndroidManifest.xml files for one project?


For the past few months, I've been developing an Android app against Cupcake (Android 1.5, API Lvl 3), and everything is working quite well (overall it is a fairly simple app).

However, recently I noticed there are two things that I would like to do:

  1. Restrict permissions to only use Internet (with API Lvl 3, it uses 2 other permissions despite only defining the Internet permission in the manifest xml)
  2. Let users move the app to SD card/external storage

Both these changes are really simple - couple of lines in AndroidManifest.xml

The solutions I found are:

  1. To restrict permissions, add: <uses-sdk android:minSdkVersion="4"/> http://developer.android.com/guide/topics/manifest/uses-sdk-element.html
  2. To allow users to move app to SD card, add (to the manifest tag): android:installLocation="auto" http://developer.android.com/guide/topics/manifest/manifest-element.html

However, solution for #1 requires API Lvl 4 (Android 1.6) and solution for #2 requires API Lvl 8 (Android 2.2)!

So does it mean that if I want both #1 and #2 as listed above, my app will only be compatible with Android 2.2+ ?

Or, is there a way to have multiple AndroidManifest.xml files for the one project? (I know the actual code for the app works for Android 1.5 and seems a waste to exclude them simply for a couple of extra lines in the manifest file)

Thanks!


Solution

  • Adding android:installLocation="auto" will not adversely effect backward compatibility -- it will just be ignored by older versions of Android.

    Setting <uses-sdk android:minSdkVersion="4"/> will prevent the app from being installed or displayed on the Market on Android 1.5 devices, however. That is its whole purpose.

    If you need to have a different set of permissions for different SDK versions, you would unfortunately need two separate projects and two separate Market listings. You could prevent the Cupcake version of your app from displaying for newer devices by adding android:maxSdkVersion="3" to the <uses-sdk> tag.