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

Error compiling to Android with cargo apk #1307

Closed
naomijub opened this issue Jun 10, 2020 · 21 comments · Fixed by #1411
Closed

Error compiling to Android with cargo apk #1307

naomijub opened this issue Jun 10, 2020 · 21 comments · Fixed by #1411

Comments

@naomijub
Copy link

Hi, I have tried to compile a project to android and I get this error.
Rust nightly:

error[E0599]: no method named `set_suspend_callback` found for reference `&winit::event_loop::EventLoopWindowTarget<T>` in the current scope
  --> /Users/julia.boeira/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/glutin-0.24.1/src/api/android/mod.rs:86:12
   |
86 |         el.set_suspend_callback(Some(Box::new(move |suspended| {
   |            ^^^^^^^^^^^^^^^^^^^^ method not found in `&winit::event_loop::EventLoopWindowTarget<T>`

error[E0615]: attempted to take value of method `SwapBuffersWithDamageKHR` on type `&api::egl::egl::Egl`
   --> /Users/julia.boeira/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/glutin-0.24.1/src/api/egl/mod.rs:694:17
    |
694 |         if !egl.SwapBuffersWithDamageKHR.is_loaded() {
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^ method, not a field
    |
help: use parentheses to call the method
    |
694 |         if !egl.SwapBuffersWithDamageKHR(_, _, _, _).is_loaded() {
    |                                         ^^^^^^^^^^^^

error[E0615]: attempted to take value of method `SwapBuffersWithDamageKHR` on type `&api::egl::egl::Egl`
   --> /Users/julia.boeira/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/glutin-0.24.1/src/api/egl/mod.rs:740:13
    |
740 |         egl.SwapBuffersWithDamageKHR.is_loaded()
    |             ^^^^^^^^^^^^^^^^^^^^^^^^ method, not a field
    |
help: use parentheses to call the method
    |
740 |         egl.SwapBuffersWithDamageKHR(_, _, _, _).is_loaded()
    |                                     ^^^^^^^^^^^^

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0599, E0615.
For more information about an error, try `rustc --explain E0599`.
error: could not compile `glutin`.

rust stable:

error[E0599]: no associated item named `EPSILON` found for type `f64` in the current scope
   --> /Users/julia.boeira/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/winit-0.22.2/src/platform_impl/android/mod.rs:101:75
    |
101 |                         if (scale_factor - old_scale_factor).abs() < f64::EPSILON {
    |                                                                           ^^^^^^^ associated item not found in `f64`
    |
help: you are looking for the module in `std`, not the primitive type
    |
101 |                         if (scale_factor - old_scale_factor).abs() < std::f64::EPSILON {
    |                                                                      ^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `winit`.

To learn more, run the command again with --verbose.
Error: Command 'cargo build --target aarch64-linux-android' had a non-zero exit code.
@katyo
Copy link

katyo commented Jun 11, 2020

@naomijub, looks like your stable rustc outdated.

@naomijub
Copy link
Author

Updated it and got

Compiling glutin v0.24.1
error[E0599]: no method named `set_suspend_callback` found for reference `&winit::event_loop::EventLoopWindowTarget<T>` in the current scope
  --> /Users/julia.boeira/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/glutin-0.24.1/src/api/android/mod.rs:86:12
   |
86 |         el.set_suspend_callback(Some(Box::new(move |suspended| {
   |            ^^^^^^^^^^^^^^^^^^^^ method not found in `&winit::event_loop::EventLoopWindowTarget<T>`

error[E0615]: attempted to take value of method `SwapBuffersWithDamageKHR` on type `&api::egl::egl::Egl`
   --> /Users/julia.boeira/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/glutin-0.24.1/src/api/egl/mod.rs:694:17
    |
694 |         if !egl.SwapBuffersWithDamageKHR.is_loaded() {
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^ method, not a field
    |
help: use parentheses to call the method
    |
694 |         if !egl.SwapBuffersWithDamageKHR(_, _, _, _).is_loaded() {
    |                                         ^^^^^^^^^^^^

error[E0615]: attempted to take value of method `SwapBuffersWithDamageKHR` on type `&api::egl::egl::Egl`
   --> /Users/julia.boeira/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/glutin-0.24.1/src/api/egl/mod.rs:740:13
    |
740 |         egl.SwapBuffersWithDamageKHR.is_loaded()
    |             ^^^^^^^^^^^^^^^^^^^^^^^^ method, not a field
    |
help: use parentheses to call the method
    |
740 |         egl.SwapBuffersWithDamageKHR(_, _, _, _).is_loaded()
    |                                     ^^^^^^^^^^^^

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0599, E0615.
For more information about an error, try `rustc --explain E0599`.
error: could not compile `glutin`.

To learn more, run the command again with --verbose.
Error: Command 'cargo build --target aarch64-linux-android' had a non-zero exit code.

@naomijub
Copy link
Author

cargo 1.44.0 (05d080faa 2020-05-06)
rustup 1.21.1 (7832b2ebe 2019-12-20)
rustc 1.44.0 (49cae5576 2020-06-01)

@kchibisov
Copy link
Member

glutin doesn't work on android now IIRC. There's a branch to make it work #1274

@Araminos
Copy link

glutin doesn't work on android now IIRC. There's a branch to make it work #1274

I have same errors with android. Unfortunately, I don't understand discussion #1274. I tried this branch with no success. Would you be able to provide path for stable version of glutin?

@PonasKovas
Copy link

Did anyone manage to compile?

@katyo katyo mentioned this issue Jul 7, 2020
7 tasks
@Kaiser1989
Copy link

I'm also trying for days to get either winit, glutin or just some hello world app running on android without success. Is there any compiling and running example out there?

@naomijub
Copy link
Author

naomijub commented Jul 8, 2020

I tried once and gave up after. Was waiting for this to be merged #1313

@Kaiser1989
Copy link

Wow, i got it 🎉

running_android

To be honest, i don't know what exactly i did. But give me some days to figure out and then i'll push all information needed.

Just so far:

  • I used the simple app project from @katyo
  • I used the the glutin branch of @katyo plus some minor changes
  • I changed some functions on Winit

@katyo
Copy link

katyo commented Jul 10, 2020

@Kaiser1989 Great. Can you publish your changes?

@Kaiser1989
Copy link

Here is my running example:

https://github.com/Kaiser1989/rust-android-example

I forked glutin and winit to get some nice and easy cargo dependencies. It's completly based on your (@katyo ) glutin_simple project. I just did some hacky changes to winit and changed the ContextBuilder config.

@Araminos
Copy link

Here is my running example:

https://github.com/Kaiser1989/rust-android-example

I forked glutin and winit to get some nice and easy cargo dependencies. It's completly based on your (@katyo ) glutin_simple project. I just did some hacky changes to winit and changed the ContextBuilder config.

Hello Philipp. Thank you so much for this grate job. This example works perfect. Grate respect. Many thanks to @katyo for support and ideas.

@LordMZTE
Copy link

Here is my running example:

https://github.com/Kaiser1989/rust-android-example

I forked glutin and winit to get some nice and easy cargo dependencies. It's completly based on your (@katyo ) glutin_simple project. I just did some hacky changes to winit and changed the ContextBuilder config.

Awesome work! I tried to use your winit fork in order to get egui running on android, but it seems that your fork is too outdated to work with the egui-winit backend. It would be great if you could update it, and maybe even get it merged. :D

@Kaiser1989
Copy link

Finally rebased my custom versions of glutin and winit to newest versions:
https://github.com/Kaiser1989/glutin
https://github.com/Kaiser1989/winit

Created Pull-Request for winit:
rust-windowing/winit#2118

and glutin:
rust-windowing/winit#2118

Adjusted my working example to use these new versions:
https://github.com/Kaiser1989/rust-android-example
https://github.com/Kaiser1989/game-gl

@PureTryOut
Copy link

@Kaiser1989 you didn't link the glutin PR.

It's #1385, not rust-windowing/winit#2118

@kodematthieu
Copy link

v0.28.0
Screenshot_2022-03-31-01-17-06-1

@Fancyflame
Copy link

glutin v0.28.0
rustc 1.60.0 stable
image

@lattice0
Copy link

Same problem #1405 anyone solved it?

@lattice0
Copy link

I made PRs for this above. Could someone help me reviewing and get them merged?

@MarijnS95
Copy link
Member

@lattice0 General comment while looking through / reviewing your PRs: Try tackling one change at a time, use a descriptive title and explain in the PR description why you are making the change and think it's the correct one. "Android fix" is an example of a nondescriptive title 😉

Thanks otherwise!

@MarijnS95
Copy link
Member

Part one of this is fixed in #1398, part two still needs some discussion but will get a proper PR soon. Thanks for bearing with us!

PureTryOut added a commit to Lea-fish/Leafish that referenced this issue Jul 1, 2022
Currently this fails because of an Android incompatibility in glutin:
rust-windowing/glutin#1307
rust-windowing/glutin#1313
PureTryOut added a commit to Lea-fish/Leafish that referenced this issue Jul 1, 2022
Currently this fails because of an Android incompatibility in glutin:
rust-windowing/glutin#1307
rust-windowing/glutin#1313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet