Created by: uKetki
The complete implementation is divided into 5 commits with detailed description are as follows:
[1/n Dynamic Feature Support] Create Android Optimiser layer and segregate responsibility of AndroidBinaryBuildable and AndroidBinaryOptimizer
- Created a light AndroidBinaryBuildable by extracting optimizer flow from buildable
- Refactored Android Buildable layer and segregated responsibility of AndroidBinaryBuildable
- Defined AndroidBinaryPathUtility class with all possible paths for aab and apk
- Added BinaryType enum to segregate apk and aab flow
Looking at the buck code for generating apk and aab, it is evident that AndroidBinaryBuildable
is bloated with a lot of responsibilities ranging from apk/aab generation, signing to optimization.
The overview of current buck architecture:
The suggestion is to refactor existing code and create two separate layers: Optimizers and Buildable which can re-use the common logic for binary generation and offload the specific implementation to the respective layers:
This approach will later help to add changes needed to support dynamic feature delivery.
[2/n Dynamic Feature Support] Update documentation of android_bundle rule to include changes required for dynamic features
- Updated documentation of android_bundle rule to include changes required for dynamic features. Creates the final dex for base and dynamic feature by utilizing the application_module_configs flag, which will internally create an APKModuleGraph for each feature and generate a respective zip file.
[3/n Dynamic Feature Support] Add new configuration flag useDynamicFeature to support dynamic features related attributes
- Defined a new configuration flag
useDynamicFeature
to support backward compatibility of AndroidBundle and AndroidBinary rule. Later this flag is used to include any specific changes related to dynamic features.
[4/n Dynamic Feature Support] Define new configuration application_modules_with_manifest to decouple the manifest behavior from the resources
- Introduced a new configuration
application_modules_with_manifest
to make base module Manifest aware of the feature's manifest. - Added manifest tags in BUCK file: manifest_skeleton, module_manifest_skeleton, and application_modules_with_manifest where AndroidManifestMerger tool will first merge all application_modules_with_manifest into module_manifest_skeleton, which is later merged into manifest_skeleton
[5/n Dynamic Feature Support] Enable buck to support dynamic features with native libraries
- This change prevents buck from packaging native code in dynamic modules into
lib.xzs
files and therefore ensures the resultantaab
file is exactly the same as if it was done by Gradle.
Resulted App Bundle overview (before changes in buck):
- All feature modules contain assets with compressed
libs.xzs
file irrespective of the state if the feature has any native library or not - Native libraries are copied for all possible APKModuleGraphs in the feature module. That's why you can see assets within
initialInstall
module has 4 sub-directories withlibs.xzs
copied across
Resulted App Bundle overview (after changes in buck):
Closes #2586 (closed) | Tested feature by including custom buck pex file in PlayFeatureDelivery sample.