Official Android Technical Documentation translation-Apk splitting Mechanism

Source: Internet
Author: User

Official Android Technical Documentation translation-Apk splitting Mechanism

 

 

Apk Splits

Directory

  1. 1Introduction
  2. 2Split by screen Density
  3. 3Split by ABI
  4. 4Variant API & Version Code supports introduction to the splitting mechanism. Compared with flavors, this allows applications to build multiple apk formats more effectively. Multi-apk only supports the following types
  5. Screen Density
  6. ABI uses the new splitting mechanism to build the hdpi version and mdpi version of the same application, and can share many tasks (such as javac, dx, proguard ). In addition, it will be considered a single variant, and the same test program will be used to test each ?? Multiple APK files.
    When you run the install or connectedCheck task on variant, Gradle automatically outputs the correct APK to each connected device.
    If you want to make another type of multi-APK (defined here: http://developer.android.com/google/play/publishing/multiple-apks.html) You can also create Flavors (API-level multi-apk instance ), each variant has its own output. Split android by screen density {... splits {density {enable true exclude ldpi, tvdpi, xxxhdpi compatibleScreens 'small', 'normal', 'large ', 'xlarge '}}
    Enable: Enable screen density splittingExclude: By default, all screen density is included. You can remove some density.Include: Screen density to be includedReset (): Reset the screen density list to contain only one empty string (this can be achieved inIncludeWhich screen density can be used together, rather than the screen density to be ignored)CompatibleScreens:List of compatible screens. This will inject the matched Node. This setting is optional.
    Note that this will always generate a general APK containing all the screen density.
    Example: densitySplit split android by ABI {... splits {abi {enable true reset () include 'x86 ', 'armeabi-v7a', 'mips 'universalApk true }}}
    Enable: Enable the ABI splitting mechanism. Exclude: By default, all ABI items are included. You can remove some ABI items. Include: Indicates which ABI to include Reset (): Reset the ABI list to include only one empty string (this can be achieved in IncludeTo indicate which ABI to use, rather than which one to ignore) UniversalApkIndicates whether to package a general version (including all ABI ). The default value is false.
    Example: ndkSanAngelesVariant API & Version Code supports warnings about obsolete APIs: Some methods contained in the current variant API have been moved to its outputs object. This method still exists, but if more than two outputs exist, the build will fail. They will be completely deleted in version 1.0. They are:
  7. Get/setOutputFile
  8. GetProcessResources
  9. GetProcessManifest
  10. GetPackageApplication/Library
  11. GetZipAlign method added on VariantOutput
  12. String getAbiFilter ()
  13. String getDensityFilter ()
  14. Task getAssemble ()
  15. String getName ()
  16. String getBaseName ()
  17. String getDirName
  18. Set/getVersionOverride // optional versionCode Rewriting
  19. Int getVersionCode () // returns the versionCode rewritten from the output, or the versioncode of variant.
    Each generated APK must have different versionCode. Similar to traversing variants to set versionCode, You can traverse the outputs of variant and set its versionCodeOverride.
    // Map for the version code ext. versionCodes = ['armeabi-v7a ': 1, mips: 2, x86: 3]
    Import com. android. build. OutputFile
    Android. applicationVariants. all {variant-> // assign different version code for each output variant. outputs. each {output-> output. versionCodeOverride = project. ext. versionCodes. get (output. getFilter (OutputFile. ABI) * 1000000 + android. defaultConfig. versionCode }}
    If both flavors and splits are used to output multiple apk files, you should still use VariantOutput. setVersionCodeOverride (int), but you should calculate the versionCode in the split information (densityFilter and abiFilter) and variant information.

     

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.