Improved android example

This commit is contained in:
Ryan Butler
2023-11-09 02:10:15 -05:00
parent 9186f92883
commit 71e3f04973
4 changed files with 34 additions and 24 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
/target /target
/Cargo.lock /Cargo.lock
\.DS_Store

View File

@@ -8,8 +8,24 @@ license = "MIT OR Apache-2.0"
[lib] [lib]
name = "bevy_openxr_android" 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.metadata.android]
package = "org.bevyengine.example_openxr_android" package = "org.bevyengine.example_openxr_android"
build_targets = ["aarch64-linux-android"] build_targets = ["aarch64-linux-android"]
@@ -21,27 +37,12 @@ icon = "@mipmap/ic_launcher"
label = "Bevy Openxr Android" label = "Bevy Openxr Android"
strip = "strip" 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] # [package.metadata.android.application]
# icon = "@mipmap/ic_launcher" # icon = "@mipmap/ic_launcher"
# label = "Bevy Example" # label = "Bevy Example"
[dependencies] [package.metadata.android.sdk]
bevy_oxr = { path = "../..", default-features = false } target_sdk_version = 32
bevy = "0.12"
openxr = { git = "https://github.com/Ralith/openxrs", features = ["mint"] }
[profile.release]
lto = "fat"
codegen-units = 1
panic = "abort"
[package.metadata.android.application.activity] [package.metadata.android.application.activity]
theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen" theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen"

View File

@@ -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/ https://developer.oculus.com/downloads/package/oculus-openxr-mobile-sdk/
`examples/android/runtime_libs/arm64-v8a/libopenxr_loader.so` `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 ## Run
Running on Meta Quest can be done with https://github.com/rust-mobile/cargo-apk. Running on Meta Quest can be done with https://github.com/rust-mobile/cargo-apk.
```sh ```sh
@@ -12,10 +22,6 @@ cargo apk run --release
``` ```
But cargo-apk is deprecated in favour of xbuild https://github.com/rust-mobile/xbuild. But cargo-apk is deprecated in favour of xbuild https://github.com/rust-mobile/xbuild.
```sh ```sh
# Install latest version of xbuild
cargo install --git https://github.com/rust-mobile/xbuild
```
```sh
# List devices and copy device string "adb:***" # List devices and copy device string "adb:***"
x devices x devices

View File

@@ -7,10 +7,12 @@ android:
label: "Bevy Openxr Android" label: "Bevy Openxr Android"
theme: "@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen" theme: "@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
meta_data: meta_data:
- name: "com.oculus.intent.category.VR"
value: "vr_only"
- name: "com.samsung.android.vr.application.mode" - name: "com.samsung.android.vr.application.mode"
value: "vr_only" value: "vr_only"
- name: "com.oculus.supportedDevices" - name: "com.oculus.supportedDevices"
value: "quest|quest2|quest3" value: "quest|quest2|quest3|questpro"
activities: activities:
- config_changes: "density|keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode" - config_changes: "density|keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode"
launch_mode: "singleTask" launch_mode: "singleTask"