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