Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions xilem/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ doc-scrape-examples = false
name = "http_cats"

# Also add to ANDROID_TARGETS in .github/ci.yml if adding a new Android example
# and update the list in xilem/examples/android/README.md.
# A custom example target which uses the same `mason.rs` file but for android
[[example]]
name = "mason_android"
Expand Down
37 changes: 36 additions & 1 deletion xilem/examples/android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,39 @@

All the examples in this folder are just glue code importing from the respective examples in the parent folder.

(TODO: Include note about how to use `cargo apk` here.)
## Running on Android

The examples are built and packaged with [`cargo-apk`](https://crates.io/crates/cargo-apk).

### Prerequisites

- The Android SDK and NDK, and the `ANDROID_HOME` and `ANDROID_NDK_ROOT` environment variables set so that `cargo-apk` can find them. See the [`cargo-apk` README](https://github.com/rust-mobile/cargo-apk) for the full requirements.
- An Android Rust target installed via `rustup`, for example:

```sh
rustup target add aarch64-linux-android
```

- `cargo-apk` itself:

```sh
cargo install cargo-apk --locked
```

### Build and run

From the repository root, build any of the examples in this folder with `cargo apk build --example <name>`, for example:

```sh
cargo apk build -p xilem --example calc_android
```

The supported examples are `calc_android`, `emoji_picker_android`, `http_cats_android`, `mason_android`, `stopwatch_android`, `to_do_mvc_android`, and `variable_clock_android`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to list these all here (not unreasonably), then we need a comment in the Cargo.toml which defines these to also update this when adding one.


To install and run the example on a connected device or running emulator, use `cargo apk run` instead:

```sh
cargo apk run -p xilem --example calc_android
```

`cargo apk check` (with the same target selectors) is used by CI to verify that every Android example still compiles for `aarch64-linux-android`.
Loading