android_tools_rs/bundletool/
mod.rs

1mod build_apks;
2mod build_bundle;
3mod extract_apks;
4mod get_device_spec;
5mod get_size_total;
6mod install_apks;
7
8pub use build_apks::*;
9pub use build_bundle::*;
10pub use extract_apks::*;
11pub use get_device_spec::*;
12pub use get_size_total::*;
13pub use install_apks::*;
14
15use std::path::{Path, PathBuf};
16
17/// ## Bundletool
18/// `bundletool` is the underlying tool that Android Studio, the Android Gradle plugin,
19/// and Google Play use to build an Android App Bundle, and convert an app bundle into
20/// the various APKs that are deployed to devices. bundletool is also available to you
21/// as a command line tool, so you can build app bundles yourself and recreate
22/// Google Play's server-side build of your app's APKs.
23///
24///
25/// ## Download bundletool
26/// If you haven't already done so, download bundletool from the [`GitHub repository`].
27///
28///
29/// ## Install bundletool
30/// In variable environments needs to create new variable BUNDLETOOL_PATH and add
31/// path to the bundletool
32///
33/// [`GitHub repository`]::https://github.com/google/bundletool/releases
34#[derive(Clone, Copy)]
35pub struct Bundletool;
36
37impl Bundletool {
38    /// Generate an APK set for all device configurations your app supports from your app
39    /// bundle
40    pub fn build_apks(self, bundle: &Path, output: &Path) -> BuildApks {
41        BuildApks::new(bundle, output)
42    }
43
44    pub fn build_bundle(self, modules: &[PathBuf], output: &Path) -> BuildBundle {
45        BuildBundle::new(modules, output)
46    }
47
48    /// To measure the estimated download sizes of APKs in an APK set as they would be
49    /// served compressed over-the-wire, use the get-size total
50    pub fn get_size_total(self, apks: &Path) -> GetSizeTotal {
51        GetSizeTotal::new(apks)
52    }
53
54    /// Extract device-specific APKs from an existing APK set
55    /// If you have an existing APK set and you want to extract from it a subset of APKs
56    /// that target a specific device configuration, you can use the extract-apks
57    /// command and specify a device specification JSON
58    pub fn extract_apks(self, apks: &Path, output_dir: &Path, device_spec: &Path) -> ExtractApks {
59        ExtractApks::new(apks, output_dir, device_spec)
60    }
61
62    /// Use the install-apks command and specify the path of the APK set to deploy your
63    /// app from an APK set
64    pub fn install_apks(self, apks: PathBuf) -> InstallApks {
65        InstallApks::new(&apks)
66    }
67
68    /// Generate and use device specification JSON files.
69    /// Bundletool is capable of generating an APK set that targets a device configuration
70    /// specified by a JSON file. To first generate a JSON file for a connected
71    /// device, run the command
72    pub fn get_device_spec(self, output: &Path) -> GetDeviceSpec {
73        GetDeviceSpec::new(output)
74    }
75}