7.1.3 运行二进制

03-运行二进制 — Comprehensive Rust

译文 · 基于 Comprehensive Rust

原文链接: https://google.github.io/comprehensive-rust/android/interoperability/with-c/run-our-binary.html

7.1.3 运行二进制

在设备上构建、推送并运行该二进制:

1
2
3
m print_birthday_card
adb push "$ANDROID_PRODUCT_OUT/system/bin/print_birthday_card" /data/local/tmp
adb shell /data/local/tmp/print_birthday_card

最后,可以运行自动生成的测试以确保绑定可用:

interoperability/bindgen/Android.bp:

1
2
3
4
5
6
7
8
9
rust_test {
    name: "libbirthday_bindgen_test",
    srcs: [":libbirthday_bindgen"],
    crate_name: "libbirthday_bindgen_test",
    test_suites: ["general-tests"],
    auto_gen_config: true,
    clippy_lints: "none", // Generated file, skip linting
    lints: "none",
}
1
atest libbirthday_bindgen_test
最后修改 August 11, 2026: 更新 (70a5af133)