Error compiling to Android with cargo apk
Closed this issue ยท 21 comments
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/github.com-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/github.com-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/github.com-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/github.com-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.
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/github.com-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/github.com-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/github.com-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.
cargo 1.44.0 (05d080faa 2020-05-06)
rustup 1.21.1 (7832b2ebe 2019-12-20)
rustc 1.44.0 (49cae5576 2020-06-01)
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?
Did anyone manage to compile?
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?
@Kaiser1989 Great. Can you publish your changes?
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.
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.
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
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
@Kaiser1989 you didn't link the glutin PR.
It's #1385, not rust-windowing/winit#2118
I made PRs for this above. Could someone help me reviewing and get them merged?
@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!