From 12cd35f48c01b77a208a8ec45edb7a14bac7c9f9 Mon Sep 17 00:00:00 2001 From: Piotr Podusowski Date: Sun, 18 May 2025 13:17:28 +0200 Subject: [PATCH] Disallow `accesskit` on Android NativeActivity, making `hello_android` working again (#6855) Follow up for https://github.com/emilk/egui/pull/6766 I wasn't sure if `compile_error` is appropriate. It felt right. --- .github/workflows/rust.yml | 4 +++- crates/eframe/src/lib.rs | 9 +++++++++ examples/hello_android/Cargo.toml | 6 +++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e75835db..d603051d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -176,7 +176,9 @@ jobs: - name: Set up cargo cache uses: Swatinem/rust-cache@v2 - - run: cargo check --features wgpu,android-native-activity --target aarch64-linux-android + # Default features disabled to turn off accesskit, which does not work + # with NativeActivity. + - run: cargo check --features wgpu,android-native-activity --target aarch64-linux-android --no-default-features working-directory: crates/eframe # --------------------------------------------------------------------------- diff --git a/crates/eframe/src/lib.rs b/crates/eframe/src/lib.rs index 63c814ab..78208eb5 100644 --- a/crates/eframe/src/lib.rs +++ b/crates/eframe/src/lib.rs @@ -144,6 +144,15 @@ #![warn(missing_docs)] // let's keep eframe well-documented #![allow(clippy::needless_doctest_main)] +// Limitation imposed by `accesskit_winit`: +// https://github.com/AccessKit/accesskit/tree/accesskit-v0.18.0/platforms/winit#android-activity-compatibility` +#[cfg(all( + target_os = "android", + feature = "accesskit", + feature = "android-native-activity" +))] +compile_error!("`accesskit` feature is only available with `android-game-activity`"); + // Re-export all useful libraries: pub use {egui, egui::emath, egui::epaint}; diff --git a/examples/hello_android/Cargo.toml b/examples/hello_android/Cargo.toml index f24b7021..b893f35e 100644 --- a/examples/hello_android/Cargo.toml +++ b/examples/hello_android/Cargo.toml @@ -17,7 +17,11 @@ crate-type = ["cdylib", "lib"] [dependencies] -eframe = { workspace = true, features = ["default", "android-native-activity"] } +eframe = { workspace = true, default-features = false, features = [ + "default_fonts", + "glow", + "android-native-activity", +] } egui_demo_lib = { workspace = true, features = ["chrono"] } # For image support: