crossbundle_tools/commands/android/native/apk/
align_apk.rs

1use crate::{error::*, types::*};
2use std::path::{Path, PathBuf};
3
4/// Aligns APK on 4-byte memory boundary.
5/// Uses `zipalign` build tools
6pub fn align_apk(
7    sdk: &AndroidSdk,
8    unaligned_apk_path: &Path,
9    package_name: &str,
10    build_dir: &Path,
11) -> Result<PathBuf> {
12    let unsigned_apk_path = build_dir.join(format!("{}.apk", package_name));
13    let mut zipalign = sdk.build_tool(bin!("zipalign"), None)?;
14    zipalign
15        .arg("-f")
16        .arg("-v")
17        .arg("4")
18        .arg(unaligned_apk_path)
19        .arg(&unsigned_apk_path);
20    zipalign.output_err(true)?;
21    Ok(unsigned_apk_path)
22}