pub struct AndroidBuilder { /* private fields */ }full only.Expand description
Android builder that handles the complete build pipeline.
This builder automates the process of compiling Rust code to Android native libraries, generating UniFFI Kotlin bindings, and packaging everything into an APK ready for deployment.
§Example
use mobench_sdk::builders::AndroidBuilder;
use mobench_sdk::{BuildConfig, BuildProfile, Target};
let builder = AndroidBuilder::new(".", "my-bench")
.verbose(true)
.output_dir("target/mobench");
let config = BuildConfig {
target: Target::Android,
profile: BuildProfile::Release,
incremental: true,
};
let result = builder.build(&config)?;Implementations§
Source§impl AndroidBuilder
impl AndroidBuilder
Sourcepub fn new(
project_root: impl Into<PathBuf>,
crate_name: impl Into<String>,
) -> Self
pub fn new( project_root: impl Into<PathBuf>, crate_name: impl Into<String>, ) -> Self
Creates a new Android builder
§Arguments
project_root- Root directory containing the bench-mobile cratecrate_name- Name of the bench-mobile crate (e.g., “my-project-bench-mobile”)
Sourcepub fn output_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn output_dir(self, dir: impl Into<PathBuf>) -> Self
Sets the output directory for mobile artifacts
By default, artifacts are written to {project_root}/target/mobench/.
Use this to customize the output location.
Sourcepub fn crate_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn crate_dir(self, dir: impl Into<PathBuf>) -> Self
Sets the explicit crate directory
By default, the builder searches for the crate in this order:
{project_root}/Cargo.toml- if it exists and has[package] namematchingcrate_name{project_root}/bench-mobile/- SDK-generated projects{project_root}/crates/{crate_name}/- workspace structure{project_root}/{crate_name}/- simple nested structure
Use this to override auto-detection and point directly to the crate.
Sourcepub fn dry_run(self, dry_run: bool) -> Self
pub fn dry_run(self, dry_run: bool) -> Self
Enables dry-run mode
In dry-run mode, the builder prints what would be done without actually making any changes. Useful for previewing the build process.
Sourcepub fn build(&self, config: &BuildConfig) -> Result<BuildResult, BenchError>
pub fn build(&self, config: &BuildConfig) -> Result<BuildResult, BenchError>
Builds the Android app with the given configuration
This performs the following steps: 0. Auto-generate project scaffolding if missing
- Build Rust libraries for Android ABIs using cargo-ndk
- Generate UniFFI Kotlin bindings
- Copy .so files to jniLibs directories
- Run Gradle to build the APK
§Returns
Ok(BuildResult)containing the path to the built APKErr(BenchError)if the build fails