Recently, the company has decided to reduce the package size, so you don’t have to delete resource files, you don’t have to delete useless files, you can directly reduce the package size

This is the sixth day of my participation in the Gwen Challenge.More article challenges

Android App Bundle

introduce

Android App Bundle is a publishing format that contains all the compiled code and resources of your application. It will hand over APK generation and signing to Google Play, which is currently not supported in the Domestic App market.

Google Play uses your App Bundle to generate and provide an optimized APK for each device configuration, so it only downloads the code and resources needed for that particular device to run your App. You no longer have to build, sign, and manage multiple APKs to optimize support for different devices, and users can get smaller and more optimized download packages.

For most application projects, building the App Bundle to support the provision of optimized APK is effortless. For example, if you already organize your App’s code and resources according to established conventions, just use Android Studio or use the command line to build signed Android App bundles and upload them to Google Play. You can then provide an optimized APK that automatically takes advantage of its benefits

Restrictions on new apps on GooglePaly

Important note: Starting in August 2021, new apps will need to use the Android App Bundle to be released on Google Play. Play Feature Delivery or Play Asset Delivery now supports new apps over 150 MB in size.

The principle of

By building an App Bundle in Android Studio, you can include everything your app needs (for all devices) : all languages, all device screen sizes, and all hardware architectures. Then, when a user downloads your app, Google Play’s new dynamic delivery only transfers code and resources that are appropriate for the user’s device. Installs that people see on the Play Store are smaller and faster to download, while also saving storage space on the device

  • (left) Old APK delivery sample – deliver all resources to the device;
  • (right) Dynamic delivery sample – deliver only necessary resources to equipment;

Android App Bundle supports modularization. Through Dynamic Delivery with split APKs, one APK can be split into multiple APKs and loaded on demand (including loading C/C++ libraries), so that developers can deliver functionality on demand at any time. Not just during installation.

  • Base Apk First installed Apk, common code and resources, so other modules are based on Base Apk
  • Configuration APKs Native Libraries And resources suitable for the current mobile phone screen resolution
  • Dynamic feature APKs modules that do not need to be loaded at first installation

Reference it to your APP

By default, it supports configuration APK generation for each set of language resources, screen density resources, and ABI libraries when building application packages. Using blocks in the android.bundle base module build.gradle file, as shown below, you can disable support for one or more configurations of APK:

android { ... . // Instead, use the bundle block to control which types of configuration APKs // you want your app bundle to support. bundle { language { // Specifies that the app bundle should not support // configuration APKs for language resources. These // resources are instead packaged with each base and // dynamic feature APK. enableSplit = false } density { // This property is set to true by default. enableSplit = true } abi { // This property is set to true by default. enableSplit =  true } } }Copy the code
  • Language language

  • Abi so package

  • Density resource packs: For example, images

  • EnableSplit True Enable False Disable

Local self-test AAB

Test your.aab files with the Bundletool tool

Download: github.com/google/bund…

Script files are available in the

Public id: Android developer reply to AppBundle for collection