Home | History | Annotate | Download | only in publishing
      1 page.title=Multiple APK Support
      2 
      3 @jd:body
      4 
      5 <div id="qv-wrapper">
      6 <div id="qv">
      7 
      8   <h2>Quickview</h2>
      9   <ul>
     10     <li>Simultaneously publish different APKs for different
     11 device configurations</li>
     12     <li>You should publish multiple APKs only when it's not possible to
     13 support all desired devices with a single APK</li>
     14   </ul>
     15 
     16   <h2>In this document</h2>
     17 <ol>
     18   <li><a href="#Concepts">Publishing Concepts</a>
     19     <ol>
     20       <li><a href="#Active">Active APKs</a></li>
     21       <li><a href="#SimpleAndAdvanced">Simple mode and advanced mode</a></li>
     22     </ol>
     23   </li>
     24   <li><a href="#HowItWorks">How Multiple APKs Work</a>
     25     <ol>
     26       <li><a href="#SupportedFilters">Supported filters</a></li>
     27       <li><a href="#Rules">Rules for multiple APKs</a></li>
     28     </ol>
     29   </li>
     30   <li><a href="#CreatingApks">Creating Multiple APKs</a>
     31     <ol>
     32       <li><a href="#VersionCodes">Assigning version codes</a></li>
     33     </ol>
     34   </li>
     35   <li><a href="#SingleAPK">Using a Single APK Instead</a>
     36     <ol>
     37       <li><a href="#TextureOptions">Supporting multiple GL textures</a></li>
     38       <li><a href="#ScreenOptions">Supporting multiple screens</a></li>
     39       <li><a href="#ApiLevelOptions">Supporting multiple API levels</a></li>
     40       <li><a href="#CpuArchOptions">Supporting multiple CPU architectures</a></li>
     41     </ol>
     42   </li>
     43 </ol>
     44 
     45   <h2>See also</h2>
     46 <ol>
     47   <li><a href="{@docRoot}google/play/expansion-files.html">APK Expansion Files</a></li>
     48   <li><a href="{@docRoot}google/play/filters.html">Filters on Google Play</a></li>
     49   <li><a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a></li>
     50   <li><a href="{@docRoot}tools/support-library/index.html">Support Library</a></li>
     51   <li><a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">Android API Levels</a></li>
     52 </ol>
     53 
     54 </div>
     55 </div>
     56 
     57 <p>Multiple APK support is a feature on Google Play that allows you to publish different APKs
     58 for your application that are each targeted to different device configurations. Each APK is a
     59 complete and independent version of your application, but they share the same application listing on
     60 Google Play and must share the same package name and be signed with the same release key. This
     61 feature is useful for cases in which your application cannot reach all desired devices with a single
     62 APK.</p>
     63 
     64 <p>Android-powered devices may differ in several ways and it's important
     65 to the success of your application that you make it available to as many devices as possible.
     66 Android applications usually run on most compatible devices with a single APK, by supplying
     67 alternative resources for different configurations (for example, different layouts for different
     68 screen sizes) and the Android system selects the appropriate resources for the device at runtime. In
     69 a few cases, however, a single APK is unable to support all device configurations, because
     70 alternative resources make the APK file too big (greater than 100MB) or other technical challenges
     71 prevent a single APK from working on all devices.</p>
     72 
     73 <p>Although <strong>we encourage you to develop and publish a single APK</strong> that supports as
     74 many device configurations as possible, doing so is sometimes not possible. To help
     75 you publish your application for as many devices as possible, Google Play allows you to
     76 publish multiple APKs under the same application listing. Google Play then supplies each APK to
     77 the appropriate devices based on configuration support you've declared in the manifest file of each
     78 APK. </p>
     79 
     80 <p>By publishing your application with multiple APKs, you can:</p>
     81 
     82 <ul>
     83   <li>Support different OpenGL texture compression formats with each APK.</li>
     84   <li>Support different screen sizes and densities with each APK.</li>
     85   <li>Support different device feature sets with each APK.</li>
     86   <li>Support different platform versions with each APK.</li>
     87   <li>Support different CPU architectures with each APK (such as for ARM, x86, and MIPS, when your
     88   app uses the <a href="{@docRoot}tools/sdk/ndk/index.html">Android NDK</a>).</li>
     89 </ul>
     90 
     91 <p>Currently, these are the only device characteristics that Google Play supports for publishing
     92 multiple APKs as the same application.</p>
     93 
     94 <p class="note"><strong>Note:</strong> You should generally use multiple APKs to support
     95 different device configurations <strong>only when your APK is too large</strong> (greater than
     96 100MB) due to the alternative resources needed for different device configurations.
     97 Using a single APK to support different configurations is always the best practice,
     98 because it makes the path for application updates simple and clear for users (and also makes
     99 your life simpler by avoiding development and publishing complexity). Read the section below about
    100 <a href="#SingleAPK">Using a Single APK Instead</a> to
    101 consider your options before publishing multiple APKs.</p>
    102 
    103 
    104 <h2 id="Concepts">Publishing Concepts</h2>
    105 
    106 <p>Before you start publishing multiple APKs on Google Play, you must understand a few
    107 concepts regarding how the Google Play Developer Console works.</p>
    108 
    109 <h3 id="Active">Active APKs</h3>
    110 
    111 <div class="sidebox-wrapper">
    112 <div class="sidebox">
    113   <h4>The difference between "Publish" and "Save"</h4>
    114   <p>When editing your application, there are two buttons on the top-right side of the page. The
    115 first button is either <strong>Publish</strong> or <strong>Unpublish</strong> and the second
    116 button is always <strong>Save</strong> (but its behavior changes).</p>
    117   <p>When your application is new or you have unpublished it from Google Play, the first
    118 button says <strong>Publish</strong>. Clicking it will publish any APKs listed as
    119 Active, making them available on Google Play. Also while your application is new
    120 or unpublished, clicking <strong>Save</strong> will save any changes you've made, such
    121 as information added to the Product details and APKs you've uploaded, but nothing is made visible on
    122 Google Play&mdash;this allows you to save your changes and sign out of the Developer Console before
    123 deciding to publish.</p>
    124  <p>Once you've published your application, the first button changes to
    125 <strong>Unpublish</strong>. Clicking it in this state unpublishes your application so that none
    126 of the APKs are available on Google Play. Also while published, the behavior of the
    127 <strong>Save</strong> button is different. In this state, clicking <strong>Save</strong> not
    128 only saves all your changes, but also publishes them to Google Play. For example, if you've
    129 already published your application and then make changes to your product details or activate new
    130 APKs, clicking <strong>Save</strong> makes all those changes live on Google Play.</p>
    131 </div>
    132 </div>
    133 
    134 
    135 <p>Before you can publish your application (whether publishing one or multiple APKs), you
    136 must "activate" your APK(s) from the <strong>APK files</strong> tab. When you activate an APK, it
    137 moves into the list of <em>Active</em> APKs. This list allows you to preview which APK(s)
    138 you're about to publish.</p>
    139 
    140 <p>If there are no errors, any "active" APK will be published to
    141 Google Play when you click the <strong>Publish</strong> button (if the application is
    142 unpublished) or when you click the <strong>Save</strong> button (if the application is
    143 already published).</p>
    144 
    145 
    146 <h3 id="SimpleAndAdvanced">Simple mode and advanced mode</h3>
    147 
    148 <p>The Google Play Developer Console provides two modes for managing the APKs associated with
    149 your application: <em>simple mode</em> and <em>advanced mode</em>. You can switch between these by
    150 clicking the
    151 link at the top-right corner of the <strong>APK files</strong> tab.</p>
    152 
    153 <p>Simple mode is the traditional way to publish an application, using one APK at a time. In
    154 simple mode, only one APK can be activated at a time. If you upload a new APK to update
    155 the application, clicking "Activate" on the new APK deactivates the currently
    156 active APK (you must then click <strong>Save</strong> to publish the new APK).</p>
    157 
    158 <p>Advanced mode allows you to activate and publish multiple APKs that are each designed for a
    159 specific set of device configurations. However, there are several rules based on the manifest
    160 declarations in each APK that determine whether you're allowed to activate each APK along with
    161 others. When you activate an APK and it violates one of the rules, you will receive an error or
    162 warning message. If it's an error, you cannot publish until you resolve the problem; if it's a
    163 warning, you can publish the activated APKs, but there might be unintended consequences as to
    164 whether your application is available for different devices. These rules are discussed more
    165 below.</p>
    166 
    167 
    168 <h2 id="HowItWorks">How Multiple APKs Work</h2>
    169 
    170 <p>The concept for using multiple APKs on Google Play is that you have just one entry in
    171 Google Play for your application, but different devices might download a different APK. This
    172 means that:</p>
    173 
    174 <ul>
    175   <li>You maintain only one set of product details (app description, icons, screenshots, etc.).
    176 This also means you <em>cannot</em> charge a different price for different APKs.</li>
    177   <li>All users see only one version of your application on Google Play, so they are not
    178 confused by different versions you may have published that are "for tablets" or
    179 "for phones."</li>
    180   <li>All user reviews are applied to the same application listing, even though users on different
    181 devices may have different APKs.</li>
    182   <li>If you publish different APKs for different versions of Android (for different API levels),
    183 then when a user's device receives a system update that qualifies them for a different APK you've
    184 published, Google Play updates the user's application to the APK designed for the higher version
    185 of Android. Any system data associated with the application is retained (the same as with normal
    186 application updates when using a single APK).</li>
    187 </ul>
    188 
    189 <p>To publish multiple APKs for the same application, you must enable <strong>Advanced mode</strong>
    190 in your application's <strong>APK files</strong> tab (as discussed in the previous section). Once
    191 in advanced mode, you can upload, activate, then publish multiple APKs for the same application. The
    192 following sections describe more about how it works.</p>
    193 
    194 
    195 <h3 id="SupportedFilters">Supported filters</h3>
    196 
    197 <p>Which devices receive each APK is determined by <a
    198 href="{@docRoot}google/play/filters.html">Google Play filters</a> that are specified by
    199 elements in the manifest file of each APK. However, Google Play allows you to publish multiple
    200 APKs only when each APK uses filters to support a variation of the following
    201 device characteristics:</p>
    202 
    203 <ul>
    204   <li><strong>OpenGL texture compression formats</strong>
    205     <p>This is based on your manifest file's <a
    206 href="{@docRoot}guide/topics/manifest/supports-gl-texture-element.html">{@code
    207 <supports-gl-texture>}</a> element(s).</p>
    208     <p>For example, when developing a game that uses OpenGL ES, you can provide one APK for
    209 devices that support ATI texture compression and a separate APK for devices
    210 that support PowerVR compression (among many others).</p>
    211   <br/>
    212   </li>
    213 
    214   <li><strong>Screen size (and, optionally, screen density)</strong>
    215     <p>This is based on your manifest file's <a
    216 href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code
    217 <supports-screens>}</a> <em>or</em> <a
    218 href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code
    219 <compatible-screens>}</a> element. You should never use both elements and you should use only
    220 <a href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code
    221 <supports-screens>}</a> when possible.</p>
    222     <p>For example, you can provide one APK that supports small and normal size screens and another
    223 APK that supports large and xlarge screens.</p>
    224 
    225     <p class="note"><strong>Note:</strong> The Android system provides strong support for
    226 applications to support all screen configurations with a single APK. You should avoid creating
    227 multiple APKs to support different screens unless absolutely necessary and instead follow the guide
    228 to <a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple
    229 Screens</a> so that your application is flexible and can adapt to all screen configurations
    230 with a single APK.</p>
    231     <p class="caution"><strong>Caution:</strong> By default, all screen size attributes in the <a
    232 href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code
    233 <supports-screens>}</a> element are "true" if you do not declare them otherwise. However,
    234 because the {@code android:xlargeScreens} attribute was added in Android 2.3 (API level
    235 9), Google Play will assume that it is "false" if your application does not set either <a
    236 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
    237 android:minSdkVersion}</a> or <a
    238 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
    239 android:targetSdkVersion}</a> to "9" or higher.</p>
    240     <p class="caution"><strong>Caution:</strong> You should not combine both <a
    241 href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code
    242 <supports-screens>}</a> and <a
    243 href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code
    244 <compatible-screens>}</a> elements in your manifest file. Using both increases the chances
    245 that you'll introduce an error due to conflicts between them. For help deciding which to use, read
    246 <a href="{@docRoot}guide/practices/screens-distribution.html">Distributing to Specific Screens</a>.
    247 If you can't avoid using both, be aware that for any conflicts in agreement between a given size,
    248 "false" will win.</p>
    249   <br/>
    250   </li>
    251 
    252   <li><strong>Device feature sets</strong>
    253     <p>This is based on your manifest file's <a
    254 href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}</a>
    255 element(s).</p>
    256     <p>For example, you can provide one APK for devices that support multitouch and another
    257 APK for devices that do not support multitouch. See
    258 <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html#features-reference">Features
    259 Reference</a> for a list of features supported by the platform.</p>
    260   <br/>
    261   </li>
    262 
    263   <li><strong>API level</strong>
    264     <p>This is based on your manifest file's <a
    265 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code <uses-sdk>}</a> element.
    266 You
    267 can use both the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
    268 android:minSdkVersion}</a> and <a
    269 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#max">{@code android:maxSdkVersion}</a>
    270 attributes to specify support for different API levels.</p>
    271     <p>For example, you can publish your application with one APK that supports API levels 4 - 7
    272 (Android 1.6 - 2.1)&mdash;using only APIs available since API level 4 or lower&mdash;and another
    273 APK that supports API levels 8 and above (Android 2.2+)&mdash;using APIs available since API level 8
    274 or lower.</p>
    275     <div class="note">
    276       <p><strong>Note:</strong></p>
    277       <ul>
    278         <li>If you use this characteristic as the factor to distinguish multiple APKs, then the APK
    279 with a higher <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
    280 android:minSdkVersion}</a> value must have a higher <a
    281 href="{@docRoot}guide/topics/manifest/manifest-element.html#vcode">{@code android:versionCode}</a>
    282 value. This is also true if two APKs overlap their device support based on a different supported
    283 filter. This ensures that when a device receives a system update, Google Play can offer the user
    284 an update for your application (because updates are based on an increase in the app version code).
    285 This requirement is described further in the section below about <a href="#Rules">Rules for
    286 multiple APKs</a>.</li>
    287         <li>You should avoid using <a
    288 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#max">{@code
    289 android:maxSdkVersion}</a> in general, because as long as you've properly developed your
    290 application with public APIs, it is always compatible with future versions of Android. If you want
    291 to publish a different APK for higher API levels, you still do not need to specify the
    292 maximum version, because if the <a
    293 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
    294 android:minSdkVersion}</a> is {@code "4"} in one APK and {@code "8"} in another, devices that
    295 support API level 8 or higher will always receive the second APK (because it's version code is
    296 higher, as per the previous note).</li>
    297     </ul>
    298   </div>
    299   </li>
    300 
    301   <li><strong>CPU architecture (ABI)</strong>
    302     <p>This is based on the native libraries included in each APK (which are
    303     determined by the architectures you declare in the {@code Application.mk}
    304     file) when using the Android NDK.</p></li>
    305 </ul>
    306 
    307 <p>Other manifest elements that enable <a
    308 href="{@docRoot}google/play/filters.html">Google Play filters</a>&mdash;but are not
    309 listed above&mdash;are still applied for each APK as usual. However, Google Play does not allow
    310 you to publish separate APKs based on variations of those device characteristics. Thus, you cannot
    311 publish multiple APKs if the above listed filters are the same for each APK (but the APKs differ
    312 based on other characteristics in the manifest or APK). For
    313 example, you cannot provide different APKs that differ purely on the <a
    314 href="{@docRoot}guide/topics/manifest/uses-configuration-element.html">{@code
    315 <uses-configuration>}</a> characteristics.</p>
    316 
    317 
    318 
    319 <h3 id="Rules">Rules for multiple APKs</h3>
    320 
    321 <p>Before you enable advanced mode to publish multiple APKs for your application, you need to
    322 understand the following rules that define how publishing multiple APKs works:</p>
    323 
    324 <ul>
    325   <li>All APKs you publish for the same application <strong>must have the same package
    326 name and be signed with the same certificate key</strong>.</li>
    327 
    328   <li>Each APK <strong>must have a different version code</strong>, specified by the
    329 <a href="{@docRoot}guide/topics/manifest/manifest-element.html#vcode">{@code
    330 android:versionCode}</a> attribute.</li>
    331 
    332   <li>Each APK <strong>must not exactly match the configuration support of another APK</strong>.
    333     <p>That is, each APK must declare slightly different support for at least one of
    334 the <a href="#SupportedFilters">supported Google Play filters</a> (listed above).</p>
    335     <p>Usually, you will differentiate your APKs based on a specific characteristic (such as the
    336 supported texture compression formats), and thus, each APK will declare support for different
    337 devices. However, it's OK to publish multiple APKs that overlap their support slightly. When two
    338 APKs do overlap (they support some of the same device configurations), a device that falls within
    339 that overlap range will receive the APK with a higher version code (defined by <a
    340 href="{@docRoot}guide/topics/manifest/manifest-element.html#vcode">{@code
    341 android:versionCode}</a>).</p></li>
    342 
    343   <li>You cannot activate a new APK that has a version code lower than that of the APK it's
    344 replacing. For example, say you have an active APK for screen sizes small - normal with version code
    345 0400, then try to replace it with an APK for the same screen sizes with version code 0300. This
    346 raises an error, because it means users of the previous APK will not be able to update the
    347 application.</li>
    348 
    349   <li>An APK that requires a <strong>higher API level</strong> must have a <strong>higher
    350 version code</strong>.
    351     <p>This is true only when either: the APKs differ based <em>only</em> on the
    352 supported API levels (no other <a href="#SupportedFilters">supported filters</a>
    353 distinguish the APKs from each other) <em>or</em> when the APKs do use another supported filter, but
    354 there is an overlap between the APKs within that filter.</p>
    355     <p>This is important because a user's device receives an application update from
    356 Google Play only if the version code for the APK on Google Play is higher than the version
    357 code of the APK currently on the device. This ensures that if a device receives a system update that
    358 then qualifies it to install the APK for higher API levels, the device receives an application
    359 update because the version code increases.</p>
    360 <p class="note"><strong>Note:</strong> The size of the version code increase is irrelevant; it
    361 simply needs to be larger in the version that supports higher API levels.</p>
    362     <p>Here are some examples:</p>
    363     <ul>
    364       <li>If an APK you've uploaded for API levels 4 and above (Android 1.6+) has a version code of
    365 {@code 0400}, then an APK for API levels 8 and above (Android 2.2+) must be {@code 0401} or
    366 greater. In this case, the API level is the only supported filter used, so the version codes
    367 <strong>must increase</strong> in correlation with the API level support for each APK, so that users
    368 get an update when they receive a system update.</li>
    369       <li>If you have one APK that's for API level 4 (and above) <em>and</em> small -
    370 large screens, and another APK for API level 8 (and above) <em>and</em> large - xlarge screens, then
    371 the version codes <strong>must increase</strong> in correlation with the API levels.
    372 In this case, the API level filter is used to
    373 distinguish each APK, but so is the screen size. Because the screen sizes overlap (both APKs
    374 support large screens), the version codes must still be in order. This ensures that a large screen
    375 device that receives a system update to API level 8 will receive an update for the second
    376 APK.</li>
    377       <li>If you have one APK that's for API level 4 (and above) <em>and</em> small -
    378 normal screens, and another APK for API level 8 (and above) <em>and</em> large - xlarge
    379 screens, then the version codes <strong>do not need to increase</strong> in correlation with the API
    380 levels. Because there is no overlap within the screen size filter, there are no devices that
    381 could potentially move between these two APKs, so there's no need for the version codes to
    382 increase from the lower API level to the higher API level.</li>
    383       <li>If you have one APK that's for API level 4 (and above) <em>and</em> ARMv7 CPUs,
    384 and another APK for API level 8 (and above) <em>and</em> ARMv5TE CPUs,
    385 then the version codes <strong>must increase</strong> in correlation with the API levels.
    386 In this case, the API level filter is used to
    387 distinguish each APK, but so is the CPU architecture. Because an APK with ARMv5TE libraries is
    388 compatible with devices that have an ARMv7 CPU, the APKs overlap on this characteristic.
    389 As such, the version code for the APK that supports API level 8 and above must be higher.
    390 This ensures that a device with an ARMv7 CPU that receives a system update to API level 8
    391 will receive an update for the second APK that's designed for API level 8.
    392 However, because this kind of update results in the ARMv7 device using an APK that's not
    393 fully optimized for that device's CPU, you should provide an
    394 APK for both the ARMv5TE and the ARMv7 architecture at each API level in order to optimize
    395 the app performance on each CPU.
    396 <strong>Note:</strong> This applies <em>only</em> when comparing APKs with the ARMv5TE and
    397 ARMv7 libraries, and not when comparing other native libraries.</li>
    398     </ul>
    399   </li>
    400 
    401 </ul>
    402 
    403 <p>Failure to abide by the above rules results in an error on the Google Play Developer Console
    404 when you activate your APKs&mdash;you will be unable to publish your application until you
    405 resolve the error.</p>
    406 
    407 <p>There are other conflicts that might occur when you activate your APKs, but which will result
    408 in warnings rather than errors. Warnings can be caused by the following:</p>
    409 
    410 <ul>
    411   <li>When you modify an APK to "shrink" the support for a device's characteristics and no other
    412 APKs support the devices that then fall outside the supported range. For example, if an APK
    413 currently supports small and normal size screens and you change it to support only small screens,
    414 then you have shrunk the pool of supported devices and some devices will no longer see your
    415 application on Google Play. You can resolve this by adding another APK that supports normal size
    416 screens so that all previously-supported devices are still supported.</li>
    417 
    418   <li>When there are "overlaps" between two or more APKs. For example, if an APK supports screen
    419 sizes small, normal, and large, while another APK supports sizes large and xlarge, there is an
    420 overlap, because both APKs support large screens. If you do not resolve this, then devices that
    421 qualify for both APKs (large screen devices in the example) will receive whichever APK has the
    422 highest version code.
    423   <p class="note"><strong>Note:</strong> If you're creating separate APKs for different CPU
    424   architectures, be aware that an APK for ARMv5TE will overlap with an APK for ARMv7. That is,
    425   an APK designed for ARMv5TE is compatible with an ARMv7 device,
    426 but the reverse is not true (an APK with only the ARMv7 libraries is
    427 <em>not</em> compatible with an ARMv5TE device).</li>
    428 </ul>
    429 
    430 <p>When such conflicts occur, you will see a warning message, but you can still publish your
    431 application.</p>
    432 
    433 
    434 
    435 <h2 id="CreatingApks">Creating Multiple APKs</h2>
    436 
    437 <p>Once you decide to publish multiple APKs, you probably need to create separate
    438 Android projects for each APK you intend to publish so that you can appropriately develop them
    439 separately. You can do this by simply duplicating your existing project and give it a new name.
    440 (Alternatively, you might use a build system that can output different resources&mdash;such
    441 as textures&mdash;based on the build configuration.)</p>
    442 
    443 <p class="note"><strong>Tip:</strong> One way to avoid duplicating large portions of your
    444 application code is to use a <a
    445 href="{@docRoot}tools/projects/index.html#LibraryProjects">library project</a>. A library
    446 project holds shared code and resources, which you can include in your actual application
    447 projects.</p>
    448 
    449 <p>When creating multiple projects for the same application, it's a good practice to identify each
    450 one with a name that indicates the device restrictions to be placed on the APK, so you can
    451 easily identify them. For example, "HelloWorld_8" might be a good name for an
    452 application designed for API level 8 and above.</p>
    453 
    454 <p class="note"><strong>Note:</strong> All APKs you publish for the same application
    455 <strong>must have the same package name and be signed with the same certificate key</strong>. Be
    456 sure you also understand each of the <a href="#Rules">Rules for multiple APKs</a>.</p>
    457 
    458 
    459 <h3 id="VersionCodes">Assigning version codes</h3>
    460 
    461 <p>Each APK for the same application <strong>must have a unique version code</strong>, specified by
    462 the <a href="{@docRoot}guide/topics/manifest/manifest-element.html#vcode">{@code
    463 android:versionCode}</a> attribute. You must be careful about assigning version codes when
    464 publishing multiple APKs, because they must each be different, but in some
    465 cases, must or should be defined in a specific order, based on the configurations that each APK
    466 supports.</p>
    467 
    468 <h4>Ordering version codes</h4>
    469 
    470 <p>An APK that requires a higher API level must usually have a higher version code. For example, if
    471 you create two APKs to support different API levels, the APK for the higher API levels must have the
    472 higher version code. This ensures that if a device receives a system update that then qualifies it
    473 to install the APK for higher API levels, the user receives a notification to update the app. For
    474 more information about how this requirement applies, see the section above about <a
    475 href="#Rules">Rules for multiple APKs</a>.</p>
    476 
    477 <p>You should also consider how the order of version codes might affect which APK your users
    478 receive either due to overlap between coverage of different APKs or future changes you might make to
    479 your APKs.</p>
    480 
    481 <p>For example, if you have different APKs based on screen size, such as one for small - normal and
    482 one for large - xlarge, but foresee a time when you will change the APKs to be one for small and one
    483 for normal - xlarge, then you should make the version code for the large - xlarge APK be higher.
    484 That way, a normal size device will receive the appropriate update when you make the change, because
    485 the version code increases from the existing APK to the new APK that now supports the device. </p>
    486 
    487 <p>Also, when creating multiple APKs that differ based on support for different OpenGL texture
    488 compression formats, be aware that many devices support multiple formats. Because a device
    489 receives the APK with the highest version code when there is an overlap in coverage between two
    490 APKs, you should order the version codes among your APKs so that the APK with the
    491 preferred compression format has the highest version code. For example, you might want to perform
    492 separate builds for your app using PVRTC, ATITC, and ETC1 compression formats. If you prefer these
    493 formats in this exact order, then the APK that uses PVRTC should have the highest version code, the
    494 APK that uses ATITC has a lower version code, and the version with ETC1 has the lowest. Thus, if a
    495 device supports both PVRTC and ETC1, it receives the APK with PVRTC, because it has the highest
    496 version code.</p>
    497 
    498 
    499 <h4>Using a version code scheme</h4>
    500 
    501 <p>In order to allow different APKs to update their version codes independent of others (for
    502 example, when you fix a bug in only one APK, so don't need to update all APKs), you should use a
    503 scheme for your version codes that
    504 provides sufficient room between each APK so that you can increase the code in one without requiring
    505 an increase in others. You should also include your actual version name in the code (that is, the
    506 user visible version assigned to <a
    507 href="{@docRoot}guide/topics/manifest/manifest-element.html#vname">{@code android:versionName}</a>),
    508 so that it's easy for you to associate the version code and version name.</p>
    509 
    510 <p class="note"><strong>Note:</strong> When you increase the version code for an APK, Google
    511 Play will prompt users of the previous version to update the application. Thus, to avoid
    512 unnecessary updates, you should not increase the version code for APKs that do not actually
    513 include changes.</p>
    514 
    515 <p>We suggest using a version code with at least 7 digits: integers that represent
    516 the supported configurations are in the higher order bits, and the version name (from <a
    517 href="{@docRoot}guide/topics/manifest/manifest-element.html#vname">{@code
    518 android:versionName}</a>) is in the lower order bits. For example, when the application version
    519 name is 3.1.0, version codes for an API level 4
    520 APK and an API level 11 APK would be something like 0400310 and 1100310, respectively. The first
    521 two digits are reserved for the API Level (4 and 11, respectively), the middle two digits are for
    522 either screen sizes or GL texture formats (not used in these examples), and the last three digits
    523 are for the application's version name (3.1.0). Figure 1 shows two examples that split based on both
    524 the platform version (API Level) and screen size.</p>
    525 
    526 <img src="{@docRoot}images/market/version-codes.png" alt="" />
    527 <p class="img-caption"><strong>Figure 1.</strong> A suggested scheme for your version codes,
    528 using the first two digits for the API Level, the second and third digits for the minimum and
    529 maximum screen size (1 - 4 indicating each of the four sizes) or to denote the texture formats
    530 and the last three digits for the app version.</p>
    531 
    532 <p>This scheme for version codes is just a suggestion for how you should establish a
    533 pattern that is scalable as your application evolves. In particular, this scheme doesn't
    534 demonstrate a solution for identifying different texture compression formats. One option might be
    535 to define your own table that specifies a different integer to each of the different
    536 compression formats your application supports (for example, 1 might correspond to ETC1 and 2 is
    537 ATITC, and so on).</p>
    538 
    539 <p>You can use any scheme you want, but you should carefully consider how future versions of your
    540 application will need to increase their version codes and how devices can receive updates when
    541 either the device configuration changes (for example, due to a system update) or when you modify the
    542 configuration support for one or several of the APKs.</p>
    543 
    544 
    545 
    546 
    547 <h2 id="SingleAPK">Using a Single APK Instead</h2>
    548 
    549 <p><strong>Creating multiple APKs for your application is not the normal procedure</strong> for
    550 publishing an application on Google Play. In most cases, you should be able to publish your
    551 application to most users with a single APK and we encourage that you do so. When you encounter
    552 a situation in which using a single APK becomes difficult, you should carefully consider all your
    553 options before deciding to publish multiple APKs.</p>
    554 
    555 <p>First of all, there are a few key benefits to developing a single APK that supports all
    556 devices:</p>
    557 
    558 <ul>
    559   <li><strong>Publishing and managing your application is easier.</strong>
    560     <p>With only one APK to worry about at any given time, you're less likely to become confused by
    561 which APK is what. You also don't have to keep track of multiple version codes for each
    562 APK&mdash;by using only one APK, you can simply increase the version code with each release and
    563 be done.</p>  </li>
    564   <li><strong>You need to manage only a single code base.</strong>
    565     <p>Although you can use a <a
    566 href="{@docRoot}tools/projects/index.html#LibraryProjects">library project</a>
    567 to share code between multiple Android projects, it's still likely that you'll reproduce some code
    568 across each project and this could become difficult to manage, especially when resolving
    569 bugs.</p></li>
    570   <li><strong>Your application can adapt to device configuration changes.</strong>
    571     <p>By creating a single APK that contains all the resources for each device configuration, your
    572 application can adapt to configuration changes that occur at runtime. For example, if the user docks
    573 or otherwise connects a handset device to a larger screen, there's a chance that this will invoke a
    574 system configuration change to support the larger screen. If you include all resources for different
    575 screen configurations in the same APK, then your application will load alternative resources and
    576 optimize the user experience for the new interface.</p>
    577   </li>
    578   <li><strong>App restore across devices just works.</strong>
    579     <p>If a user has enabled data backup on his or her current device and then buys a new device
    580 that has a different configuration, then when the user's apps are automatically restored during
    581 setup, the user receives your application and it runs using the resources optimized for that device.
    582 For example, on a new tablet, the user receives your application and it runs with your
    583 tablet-optimized resources. This restore
    584 process does not work across different APKs, because each APK can potentially have different
    585 permissions that the user has not agreed to, so Google Play may not restore the application at
    586 all. (If you use multiple APKs, the user receives either the exact same APK if it's compatible or
    587 nothing at all and must manually download your application to get the APK designed for the new
    588 device.)</p></li>
    589 </ul>
    590 
    591 <p>The following sections describe some of the other options you should use to support multiple
    592 device configurations before deciding to publish multiple APKs.</p>
    593 
    594 
    595 
    596 <h3 id="TextureOptions">Supporting multiple GL textures</h3>
    597 
    598 <p>To support multiple types of GL textures with a single APK, your application should query the GL
    599 texture formats supported on the device and then use the appropriate resources or download
    600 them from a web server. For example, in order to keep the size of your APK small, you can query the
    601 device's support for different GL texture formats when the application starts for the first time and
    602 then download only the textures you need for that device.</p>
    603 
    604 <p>For maximum performance and compatibility, your application should use ETC1 textures wherever it
    605 doesn't impact the visual quality. However, because ETC1 cannot deal with images that have drastic
    606 chroma changes, such as line art and (most) text, and doesn't support alpha, it may not the best
    607 format for all textures.</p>
    608 
    609 <p>With a single APK, you should try to use ETC1 textures and uncompressed textures whenever
    610 reasonable, and consider the use of PVRTC, ATITC, or DXTC as a last resort when ETC1 does not
    611 suffice.</p>
    612 
    613 <p>Here's an example query for supported texture compression formats from inside a
    614 {@link android.opengl.GLSurfaceView.Renderer GLSurfaceView.Renderer}:</p>
    615 
    616 <pre>
    617 public void onSurfaceChanged(GL10 gl, int w, int h) {
    618     String extensions = gl.glGetString(GL10.GL_EXTENSIONS);
    619     Log.d("ExampleActivity", extensions);
    620 }
    621 </pre>
    622 
    623 <p>This returns a string that lists each of the supported compression formats.</p>
    624 
    625 
    626 
    627 <h3 id="ScreenOptions">Supporting multiple screens</h3>
    628 
    629 <p>Unless your APK file exceeds the Google Play size limit of 100MB, supporting multiple screens
    630 should always be done with a single APK. Since Android 1.6, the Android system manages most of the
    631 work required for your application to run successfully on a variety of screen sizes and
    632 densities.</p>
    633 
    634 <p>To further optimize your application for different screen sizes and densities, you should provide
    635 <a href="{@docRoot}guide/topics/resources/providing-resources.html#AlternativeResources">alternative
    636 resources</a> such as bitmap drawables at different resolutions and different layout designs for
    637 different screen sizes.</p>
    638 
    639 <p>For more information about how to support multiple screens with a single APK, read <a
    640 href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a>.</p>
    641 
    642 <p>Additionally, you should consider using a support library from the <a
    643 href="{@docRoot}tools/support-library/index.html">Compatibility Package</a> so that you can add <a
    644 href="{@docRoot}guide/components/fragments.html">Fragments</a> to your activity designs
    645 when running on larger screens such as tablets.</p>
    646 
    647 
    648 
    649 <h3 id="ApiLevelOptions">Supporting multiple API levels</h3>
    650 
    651 <p>If you want to support as many versions of the Android platform as possible, you should use
    652 only APIs available in the lowest reasonable version. For example, your application may not require
    653 APIs newer than Android 2.1 (API Level 7), which makes an application available to
    654 over 95% of Android-powered devices (as indicated by the <a
    655 href="{@docRoot}about/dashboards/index.html">Platform Versions</a> dashboard).</p>
    656 
    657 <p>By using a support library from the <a
    658 href="{@docRoot}tools/support-library/index.html">Compatibility Package</a>, you can also use APIs
    659 from some of the latest versions (such as Android 3.0) while
    660 still supporting versions as low as Android 1.6. The support library includes APIs for <a
    661 href="{@docRoot}guide/components/fragments.html">Fragments</a>, <a
    662 href="{@docRoot}guide/components/loaders.html">Loaders</a>, and more. Using the fragment
    663 APIs is particularly valuable so that you can optimize your user interface for large devices such as
    664 tablets.</p>
    665 
    666 <p>Alternatively, if you want to use some APIs that are available only in newer versions of Android
    667 (which your application can still function without), then you should consider using reflection. By
    668 using reflection, you can check whether the current device supports certain APIs. If the APIs are
    669 not available, your application can gracefully disable and hide the feature.</p>
    670 
    671 <p>Another way to use new APIs only when running on a version that supports them is to check the
    672 API level of the current device. That is, you can query the value of {@link
    673 android.os.Build.VERSION#SDK_INT} and create different code paths depending on the API level
    674 supported by the device. For example:</p>
    675 
    676 <pre>
    677 if (android.os.Build.VERSION.SDK_INT >= 11) {
    678     // Use APIs supported by API level 11 (Android 3.0) and up
    679 } else {
    680     // Do something different to support older versions
    681 }
    682 </pre>
    683 
    684 
    685 <h3 id="CpuArchOptions">Supporting multiple CPU architectures</h3>
    686 
    687 <p>When using the Android NDK, you can create a single APK that supports multiple CPU architectures
    688 by declaring each of the desired architectures with the {@code APP_ABI} variable in the
    689 <code>Application.mk</code> file.</p>
    690 
    691 <p>For example, here's an <code>Application.mk</code> file that declares support for three
    692 different CPU architectures:</p>
    693 
    694 <pre>
    695 APP_ABI := armeabi armeabi-v7a mips
    696 APP_PLATFORM := android-9
    697 </pre>
    698