Errors trying to compile examples/hello_world for Android
Describe the bug
See https://github.com/emilk/egui/commit/7ba710ef05f6226883a44f54258971c312667dfc
Trying to compile examples/hello_world for Android I get the following errors:
PS C:\coding\rust\egui\examples\hello_world> cargo apk run --lib
Compiling arboard v2.1.1
Compiling glutin v0.28.0
error[E0433]: failed to resolve: use of undeclared type `PlatformClipboard`
--> C:\Users\Main\.cargo\registry\src\github.com-1ecc6299db9ec823\arboard-2.1.1\src\lib.rs:69:28
|
69 | Ok(Clipboard { platform: PlatformClipboard::new()? })
| ^^^^^^^^^^^^^^^^^ use of undeclared type `PlatformClipboard`
error[E0412]: cannot find type `PlatformClipboard` in this scope
--> C:\Users\Main\.cargo\registry\src\github.com-1ecc6299db9ec823\arboard-2.1.1\src\lib.rs:63:23
|
63 | pub(crate) platform: PlatformClipboard,
| ^^^^^^^^^^^^^^^^^ not found in this scope
Some errors have detailed explanations: E0412, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `arboard` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error[E0599]: no method named `set_suspend_callback` found for reference `&EventLoopWindowTarget<T>` in the current scope
--> C:\Users\Main\.cargo\registry\src\github.com-1ecc6299db9ec823\glutin-0.28.0\src\api\android\mod.rs:76:12
|
76 | el.set_suspend_callback(Some(Box::new(move |suspended| {
| ^^^^^^^^^^^^^^^^^^^^ method not found in `&EventLoopWindowTarget<T>`
error[E0615]: attempted to take value of method `SwapBuffersWithDamageKHR` on type `&api::egl::egl::Egl`
--> C:\Users\Main\.cargo\registry\src\github.com-1ecc6299db9ec823\glutin-0.28.0\src\api\egl\mod.rs:621:17
|
621 | if !egl.SwapBuffersWithDamageKHR.is_loaded() {
| ^^^^^^^^^^^^^^^^^^^^^^^^ method, not a field
|
help: use parentheses to call the method
|
621 | if !egl.SwapBuffersWithDamageKHR(_, _, _, _).is_loaded() {
| ++++++++++++
error[E0615]: attempted to take value of method `SwapBuffersWithDamageKHR` on type `&api::egl::egl::Egl`
--> C:\Users\Main\.cargo\registry\src\github.com-1ecc6299db9ec823\glutin-0.28.0\src\api\egl\mod.rs:664:13
|
664 | egl.SwapBuffersWithDamageKHR.is_loaded()
| ^^^^^^^^^^^^^^^^^^^^^^^^ method, not a field
|
help: use parentheses to call the method
|
664 | egl.SwapBuffersWithDamageKHR(_, _, _, _).is_loaded()
| ++++++++++++
Some errors have detailed explanations: E0599, E0615.
For more information about an error, try `rustc --explain E0599`.
error: could not compile `glutin` due to 3 previous errors
Error: Command `cargo build --target aarch64-linux-android --lib` had a non-zero exit code.
To Reproduce Steps to reproduce the behavior:
Checkout https://github.com/paulotten/egui/tree/android
Follow Android steps in https://github.com/paulotten/egui/blob/android/examples/hello_world/README.md
Expected behavior
Code compiles.
Screenshots
See output above.
Desktop (please complete the following information):
- OS: Compiling for Android from Windows
Compiling arboard v2.1.1
[...]
error[E0433]: failed to resolve: use of undeclared type `PlatformClipboard`
--> C:\Users\Main\.cargo\registry\src\github.com-1ecc6299db9ec823\arboard-2.1.1\src\lib.rs:69:28
|
69 | Ok(Clipboard { platform: PlatformClipboard::new()? })
| ^^^^^^^^^^^^^^^^^ use of undeclared type `PlatformClipboard`
error[E0412]: cannot find type `PlatformClipboard` in this scope
--> C:\Users\Main\.cargo\registry\src\github.com-1ecc6299db9ec823\arboard-2.1.1\src\lib.rs:63:23
|
63 | pub(crate) platform: PlatformClipboard,
| ^^^^^^^^^^^^^^^^^ not found in this scope
Some errors have detailed explanations: E0412, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `arboard` due to 2 previous errors
These errors appear to be related to https://github.com/1Password/arboard/issues/56. I seems like arboard doesn't provide clipboard support on Android.
I can get rid of these errors by disabling the clipboard feature for eframe when compiling for Android. https://github.com/paulotten/egui/commit/68cdf23d93661c4c4508f8d83118eaba4055570a
Compiling glutin v0.28.0
[...]
error[E0599]: no method named `set_suspend_callback` found for reference `&EventLoopWindowTarget<T>` in the current scope
--> C:\Users\Main\.cargo\registry\src\github.com-1ecc6299db9ec823\glutin-0.28.0\src\api\android\mod.rs:76:12
|
76 | el.set_suspend_callback(Some(Box::new(move |suspended| {
| ^^^^^^^^^^^^^^^^^^^^ method not found in `&EventLoopWindowTarget<T>`
error[E0615]: attempted to take value of method `SwapBuffersWithDamageKHR` on type `&api::egl::egl::Egl`
--> C:\Users\Main\.cargo\registry\src\github.com-1ecc6299db9ec823\glutin-0.28.0\src\api\egl\mod.rs:621:17
|
621 | if !egl.SwapBuffersWithDamageKHR.is_loaded() {
| ^^^^^^^^^^^^^^^^^^^^^^^^ method, not a field
|
help: use parentheses to call the method
|
621 | if !egl.SwapBuffersWithDamageKHR(_, _, _, _).is_loaded() {
| ++++++++++++
error[E0615]: attempted to take value of method `SwapBuffersWithDamageKHR` on type `&api::egl::egl::Egl`
--> C:\Users\Main\.cargo\registry\src\github.com-1ecc6299db9ec823\glutin-0.28.0\src\api\egl\mod.rs:664:13
|
664 | egl.SwapBuffersWithDamageKHR.is_loaded()
| ^^^^^^^^^^^^^^^^^^^^^^^^ method, not a field
|
help: use parentheses to call the method
|
664 | egl.SwapBuffersWithDamageKHR(_, _, _, _).is_loaded()
| ++++++++++++
Some errors have detailed explanations: E0599, E0615.
For more information about an error, try `rustc --explain E0599`.
error: could not compile `glutin` due to 3 previous errors
These errors appear to be related to https://github.com/rust-windowing/glutin/issues/1307. The fix for this was merged in May and should be included in glutin 0.29.0. Currently eframe is using glutin 0.28.0. So it looks like an update is needed.
Updating to glutin = { version = "0.29.0" } results in the following error when building for Windows
Compiling glutin v0.29.0
error[E0425]: cannot find value `BUFFER_AGE_EXT` in module `ffi::egl`
--> C:\Users\Main\.cargo\registry\src\github.com-1ecc6299db9ec823\glutin-0.29.0\src\api\egl\mod.rs:584:27
|
584 | ffi::egl::BUFFER_AGE_EXT as i32,
| ^^^^^^^^^^^^^^ not found in `ffi::egl`
For more information about this error, try `rustc --explain E0425`.
error: could not compile `glutin` due to previous error
https://github.com/rust-windowing/glutin/issues/1436 appears related, though possibly lacking a satisfactory solution.
Updating to
glutin = { version = "0.29.0" }results in the following error when building for WindowsCompiling glutin v0.29.0 error[E0425]: cannot find value `BUFFER_AGE_EXT` in module `ffi::egl` --> C:\Users\Main\.cargo\registry\src\github.com-1ecc6299db9ec823\glutin-0.29.0\src\api\egl\mod.rs:584:27 | 584 | ffi::egl::BUFFER_AGE_EXT as i32, | ^^^^^^^^^^^^^^ not found in `ffi::egl` For more information about this error, try `rustc --explain E0425`. error: could not compile `glutin` due to previous errorrust-windowing/glutin#1436 appears related, though possibly lacking a satisfactory solution.
I've created a PR for glutin.
For now I can work around this by updating glutin_egl_sys to 0.1.6 in Cargo.lock.
More errors now (still building for Windows):
Compiling eframe v0.18.0 (C:\coding\rust\egui\eframe)
error[E0308]: mismatched types
--> eframe\src\native\run.rs:44:29
|
44 | .build_windowed(window_builder, event_loop)
| ^^^^^^^^^^^^^^ expected struct `glutin::window::WindowBuilder`, found struct `winit::window::WindowBuilder`
|
= note: perhaps two different versions of crate `winit` are being used?
error[E0308]: mismatched types
--> eframe\src\native\run.rs:44:45
|
44 | .build_windowed(window_builder, event_loop)
| ^^^^^^^^^^ expected struct `glutin::event_loop::EventLoopWindowTarget`, found struct `winit::event_loop::EventLoop`
|
= note: expected reference `&glutin::event_loop::EventLoopWindowTarget<_>`
found reference `&winit::event_loop::EventLoop<run::RequestRepaintEvent>`
error[E0308]: mismatched types
--> eframe\src\native\run.rs:236:17
|
236 | gl_window.window(),
| ^^^^^^^^^^^^^^^^^^ expected struct `winit::window::Window`, found struct `glutin::window::Window`
|
= note: expected reference `&winit::window::Window`
found reference `&glutin::window::Window`
= note: perhaps two different versions of crate `winit` are being used?
error[E0308]: mismatched types
--> eframe\src\native\run.rs:263:51
|
263 | integration.warm_up(app.as_mut(), gl_window.window());
| ^^^^^^^^^^^^^^^^^^ expected struct `winit::window::Window`, found struct `glutin::window::Window`
|
= note: expected reference `&winit::window::Window`
found reference `&glutin::window::Window`
= note: perhaps two different versions of crate `winit` are being used?
error[E0308]: mismatched types
--> eframe\src\native\run.rs:287:13
|
286 | fn window(&self) -> &winit::window::Window {
| ---------------------- expected `&winit::window::Window` because of return type
287 | self.gl_window.window()
| ^^^^^^^^^^^^^^^^^^^^^^^ expected struct `winit::window::Window`, found struct `glutin::window::Window`
|
= note: expected reference `&winit::window::Window`
found reference `&glutin::window::Window`
= note: perhaps two different versions of crate `winit` are being used?
error[E0308]: mismatched types
--> eframe\src\native\run.rs:292:39
|
292 | .save(&mut *self.app, self.gl_window.window());
| ^^^^^^^^^^^^^^^^^^^^^^^ expected struct `winit::window::Window`, found struct `glutin::window::Window`
|
= note: expected reference `&winit::window::Window`
found reference `&glutin::window::Window`
= note: perhaps two different versions of crate `winit` are being used?
error[E0308]: mismatched types
--> eframe\src\native\run.rs:325:50
|
325 | } = integration.update(app.as_mut(), window);
| ^^^^^^ expected struct `winit::window::Window`, found struct `glutin::window::Window`
|
= note: expected reference `&winit::window::Window`
found reference `&glutin::window::Window`
= note: perhaps two different versions of crate `winit` are being used?
error[E0308]: mismatched types
--> eframe\src\native\run.rs:327:48
|
327 | integration.handle_platform_output(window, platform_output);
| ^^^^^^ expected struct `winit::window::Window`, found struct `glutin::window::Window`
|
= note: expected reference `&winit::window::Window`
found reference `&glutin::window::Window`
= note: perhaps two different versions of crate `winit` are being used?
error[E0308]: mismatched types
--> eframe\src\native\run.rs:341:54
|
341 | integration.post_rendering(app.as_mut(), window);
| ^^^^^^ expected struct `winit::window::Window`, found struct `glutin::window::Window`
|
= note: expected reference `&winit::window::Window`
found reference `&glutin::window::Window`
= note: perhaps two different versions of crate `winit` are being used?
error[E0308]: mismatched types
--> eframe\src\native\run.rs:365:54
|
365 | integration.maybe_autosave(app.as_mut(), window);
| ^^^^^^ expected struct `winit::window::Window`, found struct `glutin::window::Window`
|
= note: expected reference `&winit::window::Window`
found reference `&glutin::window::Window`
= note: perhaps two different versions of crate `winit` are being used?
error[E0308]: mismatched types
--> eframe\src\native\run.rs:392:55
|
392 | ... self.gl_window.resize(*physical_size);
| ^^^^^^^^^^^^^^ expected struct `glutin::dpi::PhysicalSize`, found struct `winit::dpi::PhysicalSize`
|
= note: expected struct `glutin::dpi::PhysicalSize<u32>`
found struct `winit::dpi::PhysicalSize<u32>`
= note: perhaps two different versions of crate `winit` are being used?
error[E0308]: mismatched types
--> eframe\src\native\run.rs:398:51
|
398 | ... self.gl_window.resize(**new_inner_size);
| ^^^^^^^^^^^^^^^^ expected struct `glutin::dpi::PhysicalSize`, found struct `winit::dpi::PhysicalSize`
|
= note: expected struct `glutin::dpi::PhysicalSize<u32>`
found struct `winit::dpi::PhysicalSize<u32>`
= note: perhaps two different versions of crate `winit` are being used?
For more information about this error, try `rustc --explain E0308`.
error: could not compile `eframe` due to 12 previous errors
note: perhaps two different versions of crate
winitare being used?
rustc may to be right on this. https://crates.io/crates/glutin/0.29.0/dependencies reports winit ^0.27.1. https://crates.io/crates/eframe/0.18.0/dependencies reports ^0.26.1.
Updating winit to 0.27.1 get me compiling successfully for both Windows and Android!
On Android I'm just getting a black screen when the app runs though.
I've also picked up a deprecated warning.
warning: use of deprecated associated function `winit::event_loop::EventLoop::<T>::with_user_event`: Use `EventLoopBuilder::<T>::with_user_event().build()` instead.
--> eframe\src\native\run.rs:427:37
|
427 | let event_loop = EventLoop::with_user_event();
| ^^^^^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
warning: `eframe` (lib) generated 1 warning
I'll look into both of these more.
So I seem to be duplicating https://github.com/emilk/egui/pull/1877. Maybe I should wait on that?
I've also picked up a deprecated warning.
Fixed. https://github.com/emilk/egui/commit/d9d4f7e9f23238fd3aba5dbd72d775c785c61f5d
On Android I'm just getting a black screen when the app runs though.
adb shows the following error:
08-10 11:08:53.546 25253 25293 I RustStdoutStderr: thread '<unnamed>' panicked at 'Cannot get the native window, it's null and will always be null before Event::Resumed and after Event::Suspended. Make sure you only call this function between those events.', C:\Users\Main\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.27.1\src\platform_impl\android\mod.rs:840:13
This looks like a stale issue now that upstream glutin has been fixed for Android (and also completely refactored to be more suitable) :)