egui-winit: Remove android-activity
dependency + add Activity
backend features
#2863
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of depending on
android-activity
directly, this exposes theandroid-native-activity
andandroid-game-activity
features from Winit (viaegui-winit
andeframe
).The overall issue here is that Android applications will very likely need to implement a subclass of
Activity
in Java or Kotlin and when usingandroid-activity
that means they will have to choose to subclassNativeActivity
orGameActivity
. Since there are significant pros and cons to each one it isn't really appropriate for Egui to force a choice here.Conceptually the
android-activity
crate is the lowest-level, runtime crate for a native Android application written in Rust and then middleware like Winit and Egui sit on top of this. With the way Cargo features work then if we want make the low-level crate configurable for applications then we don't really have any choice but to expose equivalent features via middleware frameworks (such as Egui) that applications depend on.This ensures that applications can choose what
android-activity
backend they use while also relying on Winit to decide what version ofandroid-activity
to use - without increasing the risk of a version conflict by having a direct dependency.(NB: Egui doesn't currently use the android-activity API itself)
Since
android-activity
provides theandroid_main()
entry point for Android applications it's not possible to link in multiple versions of the android-activity crate and so it's particularly important to avoid unnecessary direct dependencies that could cause a version conflict in the future.To help avoid the need for applications to directly depend on
android-activity
the Winit crate re-exports theandroid-activity
API and exposes features to configure the backend so that application crates can instead rely on Winit to pull in a compatible version ofandroid-activity
. (This way version bumps forandroid-activity
only need to be synchronized with the Winit crate).CI now enables the
android-native-activity
feature for testing.Fixes: #2829
Fixes: #2720
Closes: #2834
Cc: @ardocrat