Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved android example #38

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/Cargo.lock
\.DS_Store
37 changes: 19 additions & 18 deletions examples/android/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"
Expand Down
16 changes: 11 additions & 5 deletions examples/android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ 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
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

Expand Down Expand Up @@ -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
https://developer.android.com/studio/publish/app-signing
4 changes: 3 additions & 1 deletion examples/android/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down