From 71e3f04973b484cf8053aea7716b225b8c429f3c Mon Sep 17 00:00:00 2001 From: Ryan Butler Date: Thu, 9 Nov 2023 02:10:15 -0500 Subject: [PATCH] Improved android example --- .gitignore | 1 + examples/android/Cargo.toml | 37 +++++++++++++++++----------------- examples/android/README.md | 16 ++++++++++----- examples/android/manifest.yaml | 4 +++- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 4fffb2f..1f0c08d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target /Cargo.lock +\.DS_Store diff --git a/examples/android/Cargo.toml b/examples/android/Cargo.toml index bb38236..2a52a8a 100644 --- a/examples/android/Cargo.toml +++ b/examples/android/Cargo.toml @@ -8,8 +8,24 @@ license = "MIT OR Apache-2.0" [lib] name = "bevy_openxr_android" -crate-type = ["staticlib", "cdylib"] +crate-type = ["rlib", "cdylib"] +[target.'cfg(not(target_os="android"))'.dependencies.bevy_oxr] +path = "../../" +default-features = true + + +[dependencies] +bevy_oxr = { path = "../..", default-features = false } +bevy = "0.12" +openxr = { git = "https://github.com/Ralith/openxrs", features = ["mint"] } + +[profile.release] +lto = "fat" +codegen-units = 1 +panic = "abort" + +# This metadata is used by `cargo-apk` - `xbuild` uses the `manifest.yaml` instead. [package.metadata.android] package = "org.bevyengine.example_openxr_android" build_targets = ["aarch64-linux-android"] @@ -21,27 +37,12 @@ icon = "@mipmap/ic_launcher" label = "Bevy Openxr Android" strip = "strip" -[package.metadata.android.sdk] -target_sdk_version = 32 - - -[target.'cfg(not(target_os="android"))'.dependencies.bevy_oxr] -path = "../../" -default-features = true - # [package.metadata.android.application] # icon = "@mipmap/ic_launcher" # label = "Bevy Example" -[dependencies] -bevy_oxr = { path = "../..", default-features = false } -bevy = "0.12" -openxr = { git = "https://github.com/Ralith/openxrs", features = ["mint"] } - -[profile.release] -lto = "fat" -codegen-units = 1 -panic = "abort" +[package.metadata.android.sdk] +target_sdk_version = 32 [package.metadata.android.application.activity] theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen" diff --git a/examples/android/README.md b/examples/android/README.md index 3936403..d8a7890 100644 --- a/examples/android/README.md +++ b/examples/android/README.md @@ -5,6 +5,16 @@ Get libopenxr_loader.so from the Oculus OpenXR Mobile SDK and add it to `example https://developer.oculus.com/downloads/package/oculus-openxr-mobile-sdk/ `examples/android/runtime_libs/arm64-v8a/libopenxr_loader.so` +Also, install either `cargo-apk` (marked as deprecated): +```sh +cargo install cargo-apk +``` +or, install `xbuild` as it supersedes `cargo-apk`. Note that the `--git` is +very important here. +```sh +cargo install --git https://github.com/rust-mobile/xbuild +``` + ## Run Running on Meta Quest can be done with https://github.com/rust-mobile/cargo-apk. ```sh @@ -12,10 +22,6 @@ cargo apk run --release ``` But cargo-apk is deprecated in favour of xbuild https://github.com/rust-mobile/xbuild. ```sh -# Install latest version of xbuild -cargo install --git https://github.com/rust-mobile/xbuild -``` -```sh # List devices and copy device string "adb:***" x devices @@ -58,4 +64,4 @@ You can use `keytool` like so: keytool -genkey -v -keystore my-release-key.keystore -keyalg RSA -keysize 2048 -validity 10000 ``` For more information on key signing and why it's so important, check out this article: -https://developer.android.com/studio/publish/app-signing \ No newline at end of file +https://developer.android.com/studio/publish/app-signing diff --git a/examples/android/manifest.yaml b/examples/android/manifest.yaml index 81a41e0..9a6118c 100644 --- a/examples/android/manifest.yaml +++ b/examples/android/manifest.yaml @@ -7,10 +7,12 @@ android: label: "Bevy Openxr Android" theme: "@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen" meta_data: + - name: "com.oculus.intent.category.VR" + value: "vr_only" - name: "com.samsung.android.vr.application.mode" value: "vr_only" - name: "com.oculus.supportedDevices" - value: "quest|quest2|quest3" + value: "quest|quest2|quest3|questpro" activities: - config_changes: "density|keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode" launch_mode: "singleTask"