From 7d73e5736489ffe1dbceba398006b208f9583b95 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Mon, 12 Sep 2022 17:24:37 +0100 Subject: [PATCH] Extend compiler_error for missing feature to warn of duplicate implementations --- android-activity/src/lib.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/android-activity/src/lib.rs b/android-activity/src/lib.rs index a998f13..6a4db70 100644 --- a/android-activity/src/lib.rs +++ b/android-activity/src/lib.rs @@ -17,7 +17,23 @@ compile_error!( not(any(feature = "game-activity", feature = "native-activity")), not(doc) ))] -compile_error!("Either \"game-activity\" or \"native-activity\" must be enabled as features"); +compile_error!( + r#"Either \"game-activity\" or \"native-activity\" must be enabled as features + +If you have set one of these features then this error indicates that Cargo is trying to +link together multiple implementations of android-activity (with incompatible versions) +which is not supported. + +Since android-activity is responsible for the `android_main` entrypoint of your application +then there can only be a single implementation of android-activity linked with your application. + +You can use `cargo tree` (e.g. via `cargo ndk -t arm64-v8a tree`) to identify why multiple +versions have been resolved. + +You may need to add a `[patch]` into your Cargo.toml to ensure a specific version of +android-activity is used across all of your application's crates. +"# +); #[cfg(any(feature = "native-activity", doc))] mod native_activity;