-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android support for eframe #5318
base: master
Are you sure you want to change the base?
Conversation
Preview available at https://egui-pr-preview.github.io/pr/5318-feature/android-eframe |
76286b9
to
5ca2b43
Compare
The display safe area problem is tracked upstream at rust-windowing/winit#3910 |
You can already use eframe on android by using a custom event_loop_builder: let options = NativeOptions {
event_loop_builder: Some(Box::new(move |builder| {
builder.with_android_app(app);
})),
...
} But of course with your changes it gets easier to use eframe on android, so I think your change makes sense. Also, having an example for android is great! What's your opinion on using cargo-mobile(2) instead of cargo-apk? I think that should allow us to have an example that works with both android and iOS. |
Great question! I have some personal opinions, such as my belief that it's difficult to make cross-platform apps which target mobile in part because there are so many unclear options. None of them stand out as obviously the best. In the case of There are two different projects with practically the same name, In short, it's a mess. I haven't looked at iOS yet. I can only imagine there are more differences than similarities. |
I see, I agree that the simplicity of cargo apk is nice. Maybe we can add support for cargo-mobile to the example once someone wants to update it to support ios as well. Gave the example a try and it works great! (I already had the android sdk properly setup on my mac, so I didn't need any of the docker stuff)
|
2319192
to
6de10c3
Compare
6de10c3
to
a0dd977
Compare
I added the requested target installation commands (so many things to track, I'm embarrassed I missed that), fixed the lfs issue, and rebased. This should be ready to go now. |
Android support is "almost there". This PR pushes it just a bit further by allowing
eframe
to be used on Android. It works by smuggling theAndroidApp
required bywinit
throughNativeOptions
.The example isn't great because it doesn't leave space on the display for Android's top status bar or the lower navigation bar. I don't know what to do about that, yet. This is as far as I've managed to get it working.
Another problem is that the development environment setup is completely awful for Android unless you happen to already be a full-time Android developer with everything configured on your build host. As a Rustacean, this makes me very sad.
I've had some luck moving all of that mess to a container, adapted from https://github.com/SergioRibera/docker-rust-android. It takes care of all of the build dependencies, Android SDK, and the
cargo-apk
patches for bugs that I hit while getting the example to work on my device. (I also had to install an adb driver on my host and downloaded the Android platform-tools to get access toadb
. An alternative is exposing the USB device to Docker. On Windows hosts, that means installingusbipd
. A second alternative is using anmtp
client to upload the APK as a file with USB file transfer enabled, then manually install it through the device's file manager.)I'm not including the docker stuff in this PR, but here are the files and instructions for future reference (and it will probably simplify manual testing and CI, FWIW!)
Dockerfile
.dockerignore