Skip to content
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

Errors trying to compile examples/hello_world for Android #1896

Closed
paulotten opened this issue Aug 9, 2022 · 10 comments
Closed

Errors trying to compile examples/hello_world for Android #1896

paulotten opened this issue Aug 9, 2022 · 10 comments
Labels
android bug Something is broken

Comments

@paulotten
Copy link

paulotten commented Aug 9, 2022

Describe the bug

See 7ba710e

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
@paulotten paulotten added the bug Something is broken label Aug 9, 2022
@paulotten
Copy link
Author

   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 1Password/arboard#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. paulotten@68cdf23

@paulotten
Copy link
Author

   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 rust-windowing/glutin#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.

@paulotten
Copy link
Author

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

rust-windowing/glutin#1436 appears related, though possibly lacking a satisfactory solution.

@paulotten
Copy link
Author

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

rust-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

@paulotten
Copy link
Author

note: perhaps two different versions of crate winit are 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.

@paulotten
Copy link
Author

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.

@paulotten
Copy link
Author

So I seem to be duplicating #1877. Maybe I should wait on that?

@paulotten
Copy link
Author

I've also picked up a deprecated warning.

Fixed. d9d4f7e

@paulotten
Copy link
Author

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

@MarijnS95
Copy link
Contributor

This looks like a stale issue now that upstream glutin has been fixed for Android (and also completely refactored to be more suitable) :)

@emilk emilk added the android label Jan 11, 2024
@emilk emilk closed this as completed Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants