While designing and building your apps, you may encounter the question: Should I create multiple versions of my apk for different devices? In most instances, the answer should be an emphatic no! Unnecessarily offering multiple copies of your apk to your customers will not only make your development process more complex and painful, it may also create confusion for your users. A well-designed app that follows the best practices guidelines will be deployable and usable on almost all Android devices.
Some common scenarios when developers think they need to create multiple apks, but really don’t, include supporting:
If you are concerned about your app being installed on an unsupported environment, follow the best practices guide for Android development to avoid such issues.
After appropriately defining settings in your Android manifest file, you will want to design your app to make the necessary runtime decisions at the lowest levels in your code. For instance, you may want to implement conditional user interface logic at the latest point possible, such as altering display and layouts based on device screen and density settings. This is an ideal way to not only lower the total lines of code you write, but it may also reduce the number of bugs in your app and reduce the size of your apk.
There are, however, a handful of situations that justify creating multiple apks. These include:
If you are offering your app for a different price to customers on a smartphone versus a tablet, then submitting a separate apk for each form factor makes sense. Furthermore, if the apk file size difference is significant and you want to avoid users of your SD version unnecessarily downloading MBs of HD images, then a separate apk may be appropriate. You should consider making this decision when your apk grows larger than 8 MBs. Under these circumstances, and others that we did not cover, you will need to submit each apk individually to the Amazon Appstore as separate apps.
In conclusion, unless your reason for creating multiple versions is well-justified, we recommend that you submit only one apk per app version.
Whether you have a bug fix, enhancement or performance optimization that you want to deliver to your customers, one of your Android apps will inevitably require an upgrade. This can be either a seamless process or a painful one for your customers. To ensure that it is the former and not the latter, the Android SDK provides some simple guidelines to help you manage this process. Last week, we discussed some useful configuration settings offered through AndroidManifest.xml for designing apps to run on smartphones and tablets. This same configuration file also provides settings to version your apk.
There are two attributes you can specify to manage the versioning process of your app:
The versionName attribute is a user facing string that identifies the version of the application in use. For example, if you are upgrading for the first time, your previous versionName may be “1.0” while a minor upgrade version would be indicated by “1.1” and a major upgrade by “2.0”. The versionName attribute is primarily used for display purposes and helps users identify differences between app versions. The following is a snippet of the manifest from the Amazon MP3 App for Android:
The versionCode is the attribute that is used by the Amazon Appstore for Android to compare versions of your app. This is an integer, like 80029 in the sample manifest, not a string like the versionName. If the versionCode of an apk is greater than the versionCode of another apk, then it is considered to be newer. Of course, for this comparison to be valid, the apk package name and signature must also match. To avoid unexpected behavior, it is extremely important to keep track of your versionCode and to always increase the value whenever you are releasing a new version.