apk-rs
This independent crate is derived from the
apkpackage in rust-mobile/xbuild, commite67b501cbe0e9ca5436c223aa7ec0fe5e27544d1(apk0.4.0).
Welcome to apk-rs. you can build, sign, verfify, read, etc. Android APKs. Pure rust. you can probably get the rest from the code apis at docs.rs
Building a native app
use *;
let mut app = native_activity;
app.label
.version
.localized_string?
.icon?
.native_library?
.sign_with;
app.write?;
# Ok::
# use *;
# let mut app = native_activity;
let activity = app.manifest_mut.application_mut.element_mut.unwrap;
activity.set_attr;
# Ok::
Manifest::parse accepts a hand-written AndroidManifest.xml instead.
Signing and verifying
use ;
let identity = open?.identity?;
new.sign_file?;
let verification = verify?;
println!;
# Ok::
Reading
use Apk;
use ResourceTable;
let mut apk = open?;
println!;
let bytes = apk.read?;
print!;
# Ok::
Scope
It does mostly everything except for
- ZIP64 archives, which APK signature schemes cannot cover.
- Signing key rotation: v3.1 blocks and proof-of-rotation lineages are rejected rather than trusted unverified. APK Signature Scheme v4 and DSA signatures and verity digests are not supported. RSA, P-256, and P-384 keys are supported.
- Bag resources (styles, arrays, plurals, attributes) and nine-patch images are not compiled; ONLY simple values, files, and XML documents are. Reading supports simple values and bags; styled string spans are not exposed. I would probably take this as a PR though!
Verification establishes signature integrity and SDK scheme coverage. But certainly does not establish certificate trust or guarantee installation: DEX validity, device policy, and native symbol availability still depend on the app and device.
Framework attribute and resource IDs come from API 35 (src/android/framework.txt).
To update them, run tools/gen-framework against a newer SDK platform:
&&
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.