1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::{error::*, types::*};
use std::{
fs::create_dir_all,
path::{Path, PathBuf},
};
pub fn gen_unaligned_apk(
sdk: &AndroidSdk,
project_path: &Path,
build_dir: &Path,
manifest_path: &Path,
assets: &Option<PathBuf>,
res: &Option<PathBuf>,
package_name: &str,
target_sdk_version: u32,
) -> Result<PathBuf> {
if !build_dir.exists() {
create_dir_all(&build_dir)?;
}
let apk_path = build_dir.join(format!("{}-unaligned.apk", package_name));
let mut aapt = sdk.build_tool(bin!("aapt"), Some(project_path))?;
aapt.arg("package")
.arg("-f")
.arg("-F")
.arg(&apk_path)
.arg("-M")
.arg(manifest_path)
.arg("-I")
.arg(sdk.android_jar(target_sdk_version)?);
if let Some(res) = res {
aapt.arg("-S").arg(dunce::simplified(res));
}
if let Some(assets) = assets {
aapt.arg("-A").arg(dunce::simplified(assets));
}
aapt.output_err(true)?;
Ok(apk_path)
}