rust-mobile / android-rs-glue

Glue between Rust and Android
Apache License 2.0
905 stars 111 forks source link

Issues with cargo-apk + winit 0.19.0 #264

Open VZout opened 4 years ago

VZout commented 4 years ago

I'm trying to use cargo-apk with winit 0.19.0.

Sadly when I run cargo apk build --target ... I get the following error:

= note: /root/src/target/aarch64-linux-android/debug/deps/winittest-5ef4fa9e35ece31e.56g2qny4080fqnx9.rcgu.o: In function `android_glue::get_native_window::h9f6ad735a1f5e276':
          /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/android_glue-0.2.3/src/lib.rs:123: undefined reference to `cargo_apk_injected_glue_get_native_window'
          /root/src/target/aarch64-linux-android/debug/deps/libwinit-cb9bde4e4aad5599.rlib(winit-cb9bde4e4aad5599.winit.3jes6306-cgu.7.rcgu.o): In function `android_glue::add_sender::h7785d30e730c9e30':
          /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/android_glue-0.2.3/src/lib.rs:77: undefined reference to `cargo_apk_injected_glue_add_sender'
          /root/src/target/aarch64-linux-android/debug/deps/libwinit-cb9bde4e4aad5599.rlib(winit-cb9bde4e4aad5599.winit.3jes6306-cgu.7.rcgu.o): In function `android_glue::set_multitouch::h6397524dfc3a3cc3':
          /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/android_glue-0.2.3/src/lib.rs:102: undefined reference to `cargo_apk_injected_glue_set_multitouch'
          /root/src/target/aarch64-linux-android/debug/deps/libwinit-cb9bde4e4aad5599.rlib(winit-cb9bde4e4aad5599.winit.3jes6306-cgu.7.rcgu.o): In function `android_glue::get_native_window::h0c5643fa0d486f75':
          /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/android_glue-0.2.3/src/lib.rs:123: undefined reference to `cargo_apk_injected_glue_get_native_window'
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

What causes this issue? Is it because winit is a dependency and I don't use android_glue directly?

dvc94ch commented 4 years ago

The only way it works currently is with https://github.com/goddessfreya/winit/pull/2. The current cargo-apk implementation is in https://github.com/rust-windowing/android-ndk-rs

VZout commented 4 years ago

Thanks for your reply. I'm slightly confused. Will android-glue be completely deprecated in favor of android-ndk-rs? What is exactly the difference between glue and android-ndk-rs?

dvc94ch commented 4 years ago

yes, this repo is deprecated. the difference is that one is maintained while the other is not. @Osspial can we archive this repo?

Jasper-Bekkers commented 4 years ago

Does android-ndk-rs work with winit 0.19?

dvc94ch commented 4 years ago

No, winit needs to integrate with the native activity. Here the native-app-glue is used to interact with the native activity. But there are multiple issues with that, for example native-app-glue doesn't handle orientation changes or viewport changes when the keyboard pops up. android-ndk-rs uses the native activity directly.

dvc94ch commented 4 years ago

Thanks to @JasperDeSutter there's android support in winit master now https://github.com/rust-windowing/winit/pull/1556/