views:

211

answers:

1

I'm writing an application that is compatible with Android 1.6, but I would like to give users running Android 2.2 the option of moving the application installation to their sd card.

How can I compile my application for 1.6, but still allow 2.2 users to install it to their sd?

+2  A: 

In your manifest:

  • In <manifest>, add "android:installLocation="preferExternal"
  • Keep your current uses-sdk as "<uses-sdk android:minSdkVersion="4">"

Then go to Project > Properties > Android (on the left), change the build target to 2.2, and you're all set.

Your project will build using 2.2 (but still only requires 1.6), but devices running 1.6 will simply ignore your new "installLocation" setting in the manifest. Just be careful not to add any 2.2-introduced material in your actual code, since the compiler will no longer catch it.

Andy Zhang
Alright. Kind of a pain, but I suppose it will have to do.
GuyNoir
You can find more info here: http://developer.android.com/guide/appendix/install-location.html under "Backward Compatibility"
Andy Zhang
One recommendation: Before you roll out a new version, set the build target version back to 1.6 and do a clean build. If you get any compile errors, you know that you accidentally introduced 2.2-specific features, and your app will crash under 1.6. If everything is fine, switch back to 2.2.
EboMike