FYI this is just an experiment, based on the work of others;
I didn't make the vast majority of this code, but the section on prerequisites may be very useful to you.
See
- https://github.com/tauri-apps/cargo-mobile2
- https://github.com/gfx-rs/wgpu#supported-platforms
- https://github.com/tauri-apps/wry/blob/dev/MOBILE.md
This is an example based on agdk-egui example, using egui
, winit
and wgpu
to run egui_demo_app.
To run this on desktop, just do cargo run
like normal! For mobile, use cargo android run
and cargo apple run
respectively (or use cargo android open
and cargo apple open
to open in Android Studio and Xcode respectively).
Simply cargo run
Just run cargo android init
to generate the Android project, then cargo android run
to run it,
assuming you have the Android NDK and SDK installed (see below).
The following guide is based on https://github.com/tauri-apps/wry/blob/dev/MOBILE.md, as seen on 2023-11-01 05:29:29.
- Set env vars
sudo pacman -S jdk-openjdk export $NDK_HOME=$HOME/Android/Sdk/ndk/25.0.8775105 export $ANDROID_HOME=$HOME/Android/Sdk export $JAVA_HOME=/usr/lib/jvm/java-19-amazon-corretto
- Set the Java version
sudo archlinux-java set java-19-amazon-corretto
- Use Android Studio to install the following
- Android Sdk Platform 33
- Android SDK Platform-Tools
- NDK (Side by side) 25.0.8775105
- Android SDK Build-Tools 33.0
- Android SDK Command-line Tools
(hit the details button to see all version numbers)
- Install the rust toolchain
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
- Install cargo-mobile (2)
cargo install --git https://github.com/tauri-apps/cargo-mobile2
Legend has it you can run cargo apple run
and it may work.
But that requires macOS, so what gives.