Struct android_tools::bundletool::BuildApks
source ¡ [−]pub struct BuildApks { /* private fields */ }
Expand description
Generate a set of APKs from your app bundle
When bundletool
generates APKs from your app bundle,it includes them in a container
called an APK set archive, which uses the .apks
file extension. To generate an APK
set for all device configurations your app supports from your app bundle, use the
bundletool build-apks
command, as shown below.
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
If you want to deploy the APKs to a device, you need to also include your appâs
signing information, as shown in the command below. If you do not specify signing
information, bundletool
attempts to sign your APKs with a debug key for you.
`bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks`
`--ks=/MyApp/keystore.jks`
`--ks-pass=file:/MyApp/keystore.pwd`
`--ks-key-alias=MyKeyAlias`
`--key-pass=file:/MyApp/key.pwd`
The table below describes the various flags and options you can set when using the
bundletool build-apks
command in greater detail. Only --bundle
and --output
are
requiredâall other flags are optional
Implementations
sourceimpl BuildApks
impl BuildApks
sourcepub fn new(bundle: &Path, output: &Path) -> Self
pub fn new(bundle: &Path, output: &Path) -> Self
(Required
) Specifies the path to the app bundle you built using Android Studio.
To learn more, read [Build your project
].
(Required) Specifies the name of the output .apks
file, which contains all the
APK artifacts for your app. To test the artifacts in this file on a device, go to
the section about how to
deploy APKs to a connected device
sourcepub fn overwrite(&mut self, overwrite: bool) -> &mut Self
pub fn overwrite(&mut self, overwrite: bool) -> &mut Self
Include this flag if you want to overwrite any existing output file with the same
path you specify using the --output
option. If you donât include this flag and
the output file already exists, you get a build error
sourcepub fn aapt2(&mut self, aapt2: &Path) -> &mut Self
pub fn aapt2(&mut self, aapt2: &Path) -> &mut Self
Specifies a custom path to AAPT2. By default, bundletool
includes its own
version of AAPT2
sourcepub fn ks(&mut self, ks: &Path) -> &mut Self
pub fn ks(&mut self, ks: &Path) -> &mut Self
Specifies the path to the deployment keystore used to sign the APKs. This flag is
optional. If you donât include it, bundletool
attempts to sign your APKs with a
debug signing key
sourcepub fn ks_pass_pass(&mut self, ks_pass_pass: String) -> &mut Self
pub fn ks_pass_pass(&mut self, ks_pass_pass: String) -> &mut Self
Specifies your keystoreâs password. If youâre specifying a password in plain text,
qualify it with pass:. If youâre passing the path to a file that contains the
password, qualify it with file:. If you specify a keystore using the --ks
flag
without specifying --ks-pass
, build_apks
prompts you for a password from the
command line
sourcepub fn ks_pass_file(&mut self, ks_pass_file: &Path) -> &mut Self
pub fn ks_pass_file(&mut self, ks_pass_file: &Path) -> &mut Self
Specifies your keystoreâs password. If youâre specifying a password in plain text,
qualify it with pass:. If youâre passing the path to a file that contains the
password, qualify it with file:. If you specify a keystore using the --ks
flag
without specifying --ks-pass
, build_apks
prompts you for a password from the
command line
sourcepub fn ks_key_alias(&mut self, ks_key_alias: String) -> &mut Self
pub fn ks_key_alias(&mut self, ks_key_alias: String) -> &mut Self
Specifies the alias of the signing key you want to use
sourcepub fn key_pass_pass(&mut self, key_pass_pass: String) -> &mut Self
pub fn key_pass_pass(&mut self, key_pass_pass: String) -> &mut Self
Specifies the password for the signing key. If youâre specifying a password in plain text, qualify it with pass:. If youâre passing the path to a file that contains the password, qualify it with file:.
If this password is identical to the one for the keystore itself, you can omit this flag
sourcepub fn key_pass_file(&mut self, key_pass_file: &Path) -> &mut Self
pub fn key_pass_file(&mut self, key_pass_file: &Path) -> &mut Self
Specifies the password for the signing key. If youâre specifying a password in plain text, qualify it with pass:. If youâre passing the path to a file that contains the password, qualify it with file:.
If this password is identical to the one for the keystore itself, you can omit this flag
sourcepub fn connected_device(&mut self, connected_device: bool) -> &mut Self
pub fn connected_device(&mut self, connected_device: bool) -> &mut Self
Instructs build_apks
to build APKs that target the configuration of a connected
device. If you donât include this flag, build_apks
generates APKs for all device
configurations your app supports
sourcepub fn device_id(&mut self, device_id: String) -> &mut Self
pub fn device_id(&mut self, device_id: String) -> &mut Self
If you have more than one connected device, use this flag to specify the serial ID of the device to which you want to deploy your app
sourcepub fn device_spec(&mut self, device_spec: &Path) -> &mut Self
pub fn device_spec(&mut self, device_spec: &Path) -> &mut Self
Use this flag to provide a path to a .json
file that specifies the device
configuration you want to target. To learn more, go to the section about how to
Create and use device specification JSON files
sourcepub fn mode_universal(&mut self, mode_universal: bool) -> &mut Self
pub fn mode_universal(&mut self, mode_universal: bool) -> &mut Self
Set the mode to universal if you want build_apks
to build only a single APK that
includes all of your appâs code and resources such that the APK is compatible with
all device configurations your app supports.
Note
build_apks
includes only feature modules that specify <dist:fusing dist:include="true"/>
in their manifest in a universal APK. To learn more, read
about the [feature module manifest
].
Keep in mind, these APKs are larger than those optimized for a particular device configuration. However, theyâre easier to share with internal testers who, for example, want to test your app on multiple device configurations.
sourcepub fn local_testing(&mut self, local_testing: bool) -> &mut Self
pub fn local_testing(&mut self, local_testing: bool) -> &mut Self
Use this flag to enable your app bundle for local testing. Local testing allows for quick, iterative testing cycles without the need to upload to Google Play servers.
For an example of how to test module installation using the --local-testing
flag, see
Locally test module installs
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for BuildApks
impl Send for BuildApks
impl Sync for BuildApks
impl Unpin for BuildApks
impl UnwindSafe for BuildApks
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable ¡ sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more