diff --git a/.github/workflows/validation-jobs.yml b/.github/workflows/validation-jobs.yml index b82ca5956d857..ba585acc5a2fb 100644 --- a/.github/workflows/validation-jobs.yml +++ b/.github/workflows/validation-jobs.yml @@ -99,10 +99,10 @@ jobs: run: cargo install --force cargo-ndk - name: Build .so file - run: cargo ndk -t arm64-v8a -P 26 -o android_example/app/src/main/jniLibs build --package bevy_mobile_example + run: cargo ndk build -t aarch64-linux-android -P 26 -p bevy_mobile_example -o ./examples/mobile/android/app/src/main/jniLibs - name: Build app for Android - run: cd examples/mobile/android_example && chmod +x gradlew && ./gradlew build + run: cd ./examples/mobile/android && ./gradlew build run-examples-on-wasm: if: ${{ github.event_name == 'merge_group' }} diff --git a/docs-template/EXAMPLE_README.md.tpl b/docs-template/EXAMPLE_README.md.tpl index 2f3e994d43092..7899349caca2e 100644 --- a/docs-template/EXAMPLE_README.md.tpl +++ b/docs-template/EXAMPLE_README.md.tpl @@ -45,8 +45,8 @@ git checkout v0.4.0 - [Android](#android) - [Setup](#setup) - [Build & Run](#build--run) + - [Debugging](#debugging) - [Old phones](#old-phones) - - [About `cargo-apk`](#about-cargo-apk) - [iOS](#ios) - [Setup](#setup-1) - [Build & Run](#build--run-1) @@ -88,6 +88,10 @@ Example | Description ### Android +Example | File | Description +--- | --- | --- +`mobile` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound + #### Setup ```sh @@ -103,16 +107,20 @@ Alternatively, you can install Android Studio. #### Build & Run +**⚠️ Note:** For running the example on `x86_64`, the `--release` flag is currently required. + +**⚠️ Note:** The `-P 26` flag is currently required for building the example. If not included, you might get the error: `unable to find library -laaudio`. + To build an Android app, you first need to build shared object files for the target architecture with `cargo-ndk`: ```sh -cargo ndk -t -P 26 -o /app/src/main/jniLibs build +cargo ndk build -t -P 26 -o /app/src/main/jniLibs ``` For example, to compile to a 64-bit ARM platform: ```sh -cargo ndk -t arm64-v8a -P 26 -o android_example/app/src/main/jniLibs build +cargo ndk build -t aarch64-linux-android -P 26 -o ./android/app/src/main/jniLibs ``` Setting the output path ensures the shared object files can be found in target-specific directories under `jniLibs` where the JNI can find them. @@ -122,6 +130,7 @@ See the `cargo-ndk` [README](https://crates.io/crates/cargo-ndk) for other optio After this you can build it with `gradlew`: ```sh +cd ./android ./gradlew build ``` @@ -147,29 +156,23 @@ adb uninstall org.bevyengine.example #### Old phones -In its examples, Bevy targets the minimum Android API that Play Store -[requires](https://developer.android.com/distribute/best-practices/develop/target-sdk) to upload and update apps. -Users of older phones may want to use an older API when testing. By default, Bevy uses [`GameActivity`](https://developer.android.com/games/agdk/game-activity), which only works for Android API level 31 and higher, so if you want to use older API, you need to switch to `NativeActivity`. +**⚠️ Note:** If you are using `bevy_audio` the minimum supported Android API version is 26 (Android 8/Oreo). + +In its example, Bevy uses Android API 36 as `targetSdk` to be able to benefit from security and performance improvements. For backwards compatibility, the example specifies Android API 31 as `minSdk`. This approach is recommended in the [Android Developers documentation](https://developer.android.com/google/play/requirements/target-sdk#why-target). -Keep in mind that if you are using `bevy_audio` the minimum supported Android API version is 26 (Android 8/Oreo). +Users of older phones may want to use an older API when testing. By default, Bevy uses [`GameActivity`](https://developer.android.com/games/agdk/game-activity), which only works for Android API 31 and higher, so if you want to use an older API, you need to switch to [`NativeActivity`](https://developer.android.com/reference/android/app/NativeActivity). -To use `NativeActivity`, you need to edit it in `cargo.toml` manually like this: +To use `NativeActivity`, you need to write a custom `MainActivity.kt` using `NativeActivity` instead of `GameActivity` and add the `android-native-activity` feature to Bevy in your `Cargo.toml` like this: ```toml bevy = { version = "0.19", default-features = false, features = ["android-native-activity", ...] } ``` -Then build it as the [Build & Run](#build--run) section stated above. - -##### About `cargo-apk` - -You can also build an APK with `cargo-apk`, a simpler and deprecated tool which doesn't support `GameActivity`. If you want to use this, there is a [folder](./mobile/android_basic) inside the mobile example with instructions. +### iOS Example | File | Description --- | --- | --- -`android` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound - -### iOS +`mobile` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound #### Setup @@ -209,10 +212,6 @@ open bevy_mobile_example.xcodeproj/ which will open xcode. You then must push the zoom zoom play button and wait for the magic. -Example | File | Description ---- | --- | --- -`ios` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound - ### Wasm #### Setup diff --git a/examples/README.md b/examples/README.md index 3899b91777269..8fccf19248258 100644 --- a/examples/README.md +++ b/examples/README.md @@ -77,8 +77,8 @@ git checkout v0.4.0 - [Android](#android) - [Setup](#setup) - [Build & Run](#build--run) + - [Debugging](#debugging) - [Old phones](#old-phones) - - [About `cargo-apk`](#about-cargo-apk) - [iOS](#ios) - [Setup](#setup-1) - [Build & Run](#build--run-1) @@ -688,6 +688,10 @@ Example | Description ### Android +Example | File | Description +--- | --- | --- +`mobile` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound + #### Setup ```sh @@ -703,16 +707,20 @@ Alternatively, you can install Android Studio. #### Build & Run +**⚠️ Note:** For running the example on `x86_64`, the `--release` flag is currently required. + +**⚠️ Note:** The `-P 26` flag is currently required for building the example. If not included, you might get the error: `unable to find library -laaudio`. + To build an Android app, you first need to build shared object files for the target architecture with `cargo-ndk`: ```sh -cargo ndk -t -P 26 -o /app/src/main/jniLibs build +cargo ndk build -t -P 26 -o /app/src/main/jniLibs ``` For example, to compile to a 64-bit ARM platform: ```sh -cargo ndk -t arm64-v8a -P 26 -o android_example/app/src/main/jniLibs build +cargo ndk build -t aarch64-linux-android -P 26 -o ./android/app/src/main/jniLibs ``` Setting the output path ensures the shared object files can be found in target-specific directories under `jniLibs` where the JNI can find them. @@ -722,6 +730,7 @@ See the `cargo-ndk` [README](https://crates.io/crates/cargo-ndk) for other optio After this you can build it with `gradlew`: ```sh +cd ./android ./gradlew build ``` @@ -747,29 +756,23 @@ adb uninstall org.bevyengine.example #### Old phones -In its examples, Bevy targets the minimum Android API that Play Store -[requires](https://developer.android.com/distribute/best-practices/develop/target-sdk) to upload and update apps. -Users of older phones may want to use an older API when testing. By default, Bevy uses [`GameActivity`](https://developer.android.com/games/agdk/game-activity), which only works for Android API level 31 and higher, so if you want to use older API, you need to switch to `NativeActivity`. +**⚠️ Note:** If you are using `bevy_audio` the minimum supported Android API version is 26 (Android 8/Oreo). + +In its example, Bevy uses Android API 36 as `targetSdk` to be able to benefit from security and performance improvements. For backwards compatibility, the example specifies Android API 31 as `minSdk`. This approach is recommended in the [Android Developers documentation](https://developer.android.com/google/play/requirements/target-sdk#why-target). -Keep in mind that if you are using `bevy_audio` the minimum supported Android API version is 26 (Android 8/Oreo). +Users of older phones may want to use an older API when testing. By default, Bevy uses [`GameActivity`](https://developer.android.com/games/agdk/game-activity), which only works for Android API 31 and higher, so if you want to use an older API, you need to switch to [`NativeActivity`](https://developer.android.com/reference/android/app/NativeActivity). -To use `NativeActivity`, you need to edit it in `cargo.toml` manually like this: +To use `NativeActivity`, you need to write a custom `MainActivity.kt` using `NativeActivity` instead of `GameActivity` and add the `android-native-activity` feature to Bevy in your `Cargo.toml` like this: ```toml bevy = { version = "0.19", default-features = false, features = ["android-native-activity", ...] } ``` -Then build it as the [Build & Run](#build--run) section stated above. - -##### About `cargo-apk` - -You can also build an APK with `cargo-apk`, a simpler and deprecated tool which doesn't support `GameActivity`. If you want to use this, there is a [folder](./mobile/android_basic) inside the mobile example with instructions. +### iOS Example | File | Description --- | --- | --- -`android` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound - -### iOS +`mobile` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound #### Setup @@ -809,10 +812,6 @@ open bevy_mobile_example.xcodeproj/ which will open xcode. You then must push the zoom zoom play button and wait for the magic. -Example | File | Description ---- | --- | --- -`ios` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound - ### Wasm #### Setup diff --git a/examples/mobile/android/.gitattributes b/examples/mobile/android/.gitattributes new file mode 100644 index 0000000000000..f91f64602e6c6 --- /dev/null +++ b/examples/mobile/android/.gitattributes @@ -0,0 +1,12 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# Linux start script should use lf +/gradlew text eol=lf + +# These are Windows script files and should use crlf +*.bat text eol=crlf + +# Binary files should be left untouched +*.jar binary + diff --git a/examples/mobile/android/app/build.gradle.kts b/examples/mobile/android/app/build.gradle.kts new file mode 100644 index 0000000000000..04bb9b5e66e4b --- /dev/null +++ b/examples/mobile/android/app/build.gradle.kts @@ -0,0 +1,65 @@ +plugins { + alias(libs.plugins.android.application) +} + +kotlin { + compilerOptions { + languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_3 + jvmToolchain(8) + } +} + +android { + namespace = "org.bevyengine.example" + compileSdk = 36 + + // https://developer.android.com/reference/tools/gradle-api/9.1/com/android/build/api/dsl/DefaultConfig + defaultConfig { + applicationId = "org.bevyengine.example" + minSdk = 31 + targetSdk = 36 + // NOTE: Increase by 1 on each release + versionCode = 1 + // NOTE: Update with full semantic version on each release + versionName = "0.0.0" + // https://developer.android.com/reference/tools/gradle-api/9.1/com/android/build/api/dsl/Ndk + ndk { + abiFilters.addAll(listOf("arm64-v8a", "armeabi-v7a", "x86_64")) + } + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + // https://developer.android.com/reference/tools/gradle-api/9.1/com/android/build/api/dsl/BuildType + buildTypes { + getByName("release") { + // https://developer.android.com/topic/performance/app-optimization/enable-app-optimization + isMinifyEnabled = true + isShrinkResources = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt")) + } + } + // https://developer.android.com/reference/tools/gradle-api/9.1/com/android/build/api/dsl/CompileOptions + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + // https://developer.android.com/reference/tools/gradle-api/9.1/com/android/build/api/dsl/BuildFeatures + buildFeatures { + prefab = true + } + // https://developer.android.com/reference/tools/gradle-api/9.1/com/android/build/api/dsl/AndroidSourceSet + sourceSets { + getByName("main") { + assets { + directories += "../../../../assets" + } + } + } +} + +dependencies { + implementation(libs.appcompat) + implementation(libs.core) + implementation(libs.material) + implementation(libs.games.activity) + implementation(libs.core.ktx) +} diff --git a/examples/mobile/android/app/src/main/AndroidManifest.xml b/examples/mobile/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000000..35aa4438e4091 --- /dev/null +++ b/examples/mobile/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/examples/mobile/android/app/src/main/kotlin/org/bevyengine/example/MainActivity.kt b/examples/mobile/android/app/src/main/kotlin/org/bevyengine/example/MainActivity.kt new file mode 100644 index 0000000000000..6b16ab2651374 --- /dev/null +++ b/examples/mobile/android/app/src/main/kotlin/org/bevyengine/example/MainActivity.kt @@ -0,0 +1,49 @@ +package org.bevyengine.example + +import androidx.core.view.WindowCompat +import androidx.core.view.WindowInsetsCompat +import androidx.core.view.WindowInsetsControllerCompat +import com.google.androidgamesdk.GameActivity + +/** + * Load rust library and handle android specifics to integrate with it. + * + * + * The library is loaded at class initialization and provided by jniLibs. + */ +class MainActivity : GameActivity() { + /** + * Hide system UI if the app window is focused. + * + * + * Called when the current Window of the activity gains or loses focus. + */ + override fun onWindowFocusChanged(hasFocus: Boolean) { + // Call parent class implementation of onWindowFocusChanged to make sure that we are updating correctly. + super.onWindowFocusChanged(hasFocus) + + if (hasFocus) { + hideSystemUi() + } + } + + /** + * Hide system UI. + */ + private fun hideSystemUi() { + val windowInsetsController = + WindowCompat.getInsetsController(window, window.decorView) + + // Show bars if swiping + windowInsetsController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE + // Hide both the status bar and the navigation bar. + windowInsetsController.hide(WindowInsetsCompat.Type.systemBars()) + } + + companion object { + // Load rust library + init { + System.loadLibrary("bevy_mobile_example") + } + } +} diff --git a/assets/android-res/mipmap-mdpi/ic_launcher.png b/examples/mobile/android/app/src/main/res/mipmap/ic_launcher.png similarity index 100% rename from assets/android-res/mipmap-mdpi/ic_launcher.png rename to examples/mobile/android/app/src/main/res/mipmap/ic_launcher.png diff --git a/examples/mobile/android_example/build.gradle b/examples/mobile/android/build.gradle.kts similarity index 100% rename from examples/mobile/android_example/build.gradle rename to examples/mobile/android/build.gradle.kts diff --git a/examples/mobile/android/gradle.properties b/examples/mobile/android/gradle.properties new file mode 100644 index 0000000000000..618c4f527c901 --- /dev/null +++ b/examples/mobile/android/gradle.properties @@ -0,0 +1,12 @@ +# https://docs.gradle.org/current/userguide/build_environment.html +org.gradle.configuration-cache=true +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 + +# This should be enabled by default, but for older gradle versions this is still necessary. +# See: https://developer.android.com/build/releases/agp-9-0-0-release-notes +android.useAndroidX=true + +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true diff --git a/examples/mobile/android/gradle/gradle-daemon-jvm.properties b/examples/mobile/android/gradle/gradle-daemon-jvm.properties new file mode 100644 index 0000000000000..3095d1405042e --- /dev/null +++ b/examples/mobile/android/gradle/gradle-daemon-jvm.properties @@ -0,0 +1,12 @@ +#This file is generated by updateDaemonJvm +toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/73c462e34475aeb6509ab7ba3eda218f/redirect +toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/9e87f9444e29ce8efb3f66e8435d94b4/redirect +toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/73c462e34475aeb6509ab7ba3eda218f/redirect +toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/9e87f9444e29ce8efb3f66e8435d94b4/redirect +toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1050b2216f8beaaecc1289b17d30b586/redirect +toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/2208feeb3d4e12f412e9a450db1a842a/redirect +toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/40b4344c056b4284246d176d9701577f/redirect +toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/9e87f9444e29ce8efb3f66e8435d94b4/redirect +toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/a86b70d151aa8c1a054e80f417232fa2/redirect +toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/69a793dd932268c7d1ae9d8b855de8ed/redirect +toolchainVersion=17 diff --git a/examples/mobile/android_example/gradle/libs.versions.toml b/examples/mobile/android/gradle/libs.versions.toml similarity index 56% rename from examples/mobile/android_example/gradle/libs.versions.toml rename to examples/mobile/android/gradle/libs.versions.toml index a5d3c345599dc..d82f2f51fb9f5 100644 --- a/examples/mobile/android_example/gradle/libs.versions.toml +++ b/examples/mobile/android/gradle/libs.versions.toml @@ -1,19 +1,17 @@ [versions] -agp = "8.4.0" -junit = "4.13.2" -junitVersion = "1.1.5" -espressoCore = "3.5.1" -appcompat = "1.6.1" -material = "1.10.0" +agp = "9.1.0" +appcompat = "1.7.1" +core = "1.18.0" gamesActivity = "4.4.0" # Note: This must be compatible with `android-activity` crate used by bevy. +material = "1.13.0" +coreKtx = "1.18.0" [libraries] -junit = { group = "junit", name = "junit", version.ref = "junit" } -ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } -espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } -material = { group = "com.google.android.material", name = "material", version.ref = "material" } +core = { group = "androidx.core", name = "core", version.ref = "core" } games-activity = { group = "androidx.games", name = "games-activity", version.ref = "gamesActivity" } +material = { group = "com.google.android.material", name = "material", version.ref = "material" } +core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } diff --git a/examples/mobile/android/gradle/wrapper/gradle-wrapper.jar b/examples/mobile/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000..d997cfc60f4cf Binary files /dev/null and b/examples/mobile/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/mobile/android_example/gradle/wrapper/gradle-wrapper.properties b/examples/mobile/android/gradle/wrapper/gradle-wrapper.properties similarity index 73% rename from examples/mobile/android_example/gradle/wrapper/gradle-wrapper.properties rename to examples/mobile/android/gradle/wrapper/gradle-wrapper.properties index d38484cf25b5c..c61a118f7ddb2 100644 --- a/examples/mobile/android_example/gradle/wrapper/gradle-wrapper.properties +++ b/examples/mobile/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Thu Mar 07 11:17:51 CST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/mobile/android/gradlew b/examples/mobile/android/gradlew new file mode 100755 index 0000000000000..739907dfd1593 --- /dev/null +++ b/examples/mobile/android/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/examples/mobile/android_example/gradlew.bat b/examples/mobile/android/gradlew.bat similarity index 77% rename from examples/mobile/android_example/gradlew.bat rename to examples/mobile/android/gradlew.bat index ac1b06f93825d..c4bdd3ab8e3cc 100644 --- a/examples/mobile/android_example/gradlew.bat +++ b/examples/mobile/android/gradlew.bat @@ -1,89 +1,93 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/examples/mobile/android_example/settings.gradle b/examples/mobile/android/settings.gradle.kts similarity index 62% rename from examples/mobile/android_example/settings.gradle rename to examples/mobile/android/settings.gradle.kts index cc9e80cecf638..59b6d0a84830e 100644 --- a/examples/mobile/android_example/settings.gradle +++ b/examples/mobile/android/settings.gradle.kts @@ -12,12 +12,19 @@ pluginManagement { } } dependencyResolutionManagement { + @Suppress("UnstableApiUsage") repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + @Suppress("UnstableApiUsage") repositories { google() mavenCentral() } } -rootProject.name = "Bevy Example" -include ':app' +plugins { + // Apply the foojay-resolver plugin to allow automatic download of JDKs + id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" +} + +rootProject.name = "bevy_mobile_example" +include(":app") diff --git a/examples/mobile/android_basic/Cargo.toml b/examples/mobile/android_basic/Cargo.toml deleted file mode 100644 index d5a66368b600c..0000000000000 --- a/examples/mobile/android_basic/Cargo.toml +++ /dev/null @@ -1,68 +0,0 @@ -[package] -name = "bevy_mobile_example" -# Version is required by `cargo-apk`, though this value will never change. -version = "0.0.0" -edition = "2024" -description = "Example for building an iOS or Android app with Bevy" -publish = false -license = "MIT OR Apache-2.0" - -[lib] -name = "bevy_mobile_example" -crate-type = ["staticlib", "cdylib"] - -[dependencies] -bevy = { path = "../../", default-features = false, features = [ - "android-native-activity", - "gltf_animation", - "bevy_animation", - "bevy_asset", - "bevy_audio", - "bevy_color", - "bevy_core_pipeline", - "bevy_gilrs", - "bevy_gizmos", - "bevy_gltf", - "bevy_pbr", - "bevy_render", - "bevy_scene", - "bevy_sprite", - "bevy_state", - "bevy_text", - "bevy_ui", - "bevy_winit", - "default_font", - "hdr", - "ktx2", - "multi_threaded", - "png", - "sysinfo_plugin", - "tonemapping_luts", - "vorbis", - "webgl2", - "x11", - "zstd", -] } - -[package.metadata.android] -package = "org.bevyengine.example" -apk_name = "bevyexample" -assets = "../../assets" -resources = "../../assets/android-res" -# This strips debug symbols from the shared libraries, drastically reducing APK size. If you need them, remove the option. -strip = "strip" -build_targets = ["aarch64-linux-android", "armv7-linux-androideabi"] - -[package.metadata.android.sdk] -target_sdk_version = 33 - -[package.metadata.android.application] -icon = "@mipmap/ic_launcher" -label = "Bevy Example" - -[lints] -workspace = true - -[package.metadata.docs.rs] -rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"] -all-features = true diff --git a/examples/mobile/android_basic/readme.md b/examples/mobile/android_basic/readme.md deleted file mode 100644 index ab812b17b40c9..0000000000000 --- a/examples/mobile/android_basic/readme.md +++ /dev/null @@ -1,58 +0,0 @@ -# Basic Android Example Instruction - -This folder instructs you how to build android apps with `cargo-apk`, a deprecated Android apk building tool. - -## Setup - -```sh -rustup target add aarch64-linux-android armv7-linux-androideabi -cargo install cargo-apk -``` - -Please refer example [README](../../README.md#setup) for NDK/SDK related instructions. - -## Build & Run - -When using `cargo-apk`, it must use `NativeActivity`, so you need to edit it in `Cargo.toml` manually like this: - -```toml -bevy = { version = "0.14", default-features = false, features = ["android-native-activity", ...] } -``` - -Then the following fields must be added to `Cargo.toml`: - -```toml -[package.metadata.android] -build_targets = ["aarch64-linux-android", "armv7-linux-androideabi"] - -[package.metadata.android.sdk] -target_sdk_version = 33 -``` - -Please refer `cargo-apk` [README](https://crates.io/crates/cargo-apk) for other Android Manifest fields. - -For this example, you can replace the `Cargo.toml` with the one within this folder. - -After setup, you can run it on a device for Android development: - -```sh -cargo apk run -p bevy_mobile_example -``` - -Please refer example [README](../../README.md#debugging) for debugging instructions. - -## Old phones - -Bevy by default targets Android API level 33 in its examples which is the -[Play Store's minimum API to upload or update apps](https://developer.android.com/distribute/best-practices/develop/target-sdk). -Users of older phones may want to use an older API when testing. - -Keep in mind that if you are using `bevy_audio` the minimum supported Android API version is 26 (Android 8/Oreo). - -To use a different API, the following fields must be updated in `Cargo.toml`: - -```toml -[package.metadata.android.sdk] -target_sdk_version = >>API<< -min_sdk_version = >>API or less<< -``` diff --git a/examples/mobile/android_example/app/build.gradle b/examples/mobile/android_example/app/build.gradle deleted file mode 100644 index 94be007f51f1c..0000000000000 --- a/examples/mobile/android_example/app/build.gradle +++ /dev/null @@ -1,51 +0,0 @@ -plugins { - alias(libs.plugins.android.application) -} - -android { - namespace 'org.bevyengine.example' - compileSdk 34 - - defaultConfig { - applicationId "org.bevyengine.example" - minSdk 31 - targetSdk 33 - versionCode 1 - versionName "1.0" - // set up targets - ndk { - abiFilters 'arm64-v8a' - } - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - buildFeatures { - prefab true - } - sourceSets { - main { - assets.srcDirs += files('../../../../assets') - - res.srcDirs += files('../../../../assets/android-res') - } - } -} - -dependencies { - - implementation libs.appcompat - implementation libs.material - implementation libs.games.activity - testImplementation libs.junit - androidTestImplementation libs.ext.junit - androidTestImplementation libs.espresso.core -} diff --git a/examples/mobile/android_example/app/src/main/AndroidManifest.xml b/examples/mobile/android_example/app/src/main/AndroidManifest.xml deleted file mode 100644 index 38861e3924e60..0000000000000 --- a/examples/mobile/android_example/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/mobile/android_example/app/src/main/java/org/bevyengine/example/MainActivity.java b/examples/mobile/android_example/app/src/main/java/org/bevyengine/example/MainActivity.java deleted file mode 100644 index 91a2d5a5c1b29..0000000000000 --- a/examples/mobile/android_example/app/src/main/java/org/bevyengine/example/MainActivity.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.bevyengine.example; - -import android.view.View; - -import com.google.androidgamesdk.GameActivity; - -public class MainActivity extends GameActivity { - static { - System.loadLibrary("bevy_mobile_example"); - } - - @Override - public void onWindowFocusChanged(boolean hasFocus) { - super.onWindowFocusChanged(hasFocus); - - if (hasFocus) { - hideSystemUi(); - } - } - - private void hideSystemUi() { - View decorView = getWindow().getDecorView(); - decorView.setSystemUiVisibility( - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY - | View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_FULLSCREEN - ); - } -} \ No newline at end of file diff --git a/examples/mobile/android_example/gradle.properties b/examples/mobile/android_example/gradle.properties deleted file mode 100644 index 4387edc225e5d..0000000000000 --- a/examples/mobile/android_example/gradle.properties +++ /dev/null @@ -1,21 +0,0 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. For more details, visit -# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Enables namespacing of each library's R class so that its R class includes only the -# resources declared in the library itself and none from the library's dependencies, -# thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file diff --git a/examples/mobile/android_example/gradle/wrapper/gradle-wrapper.jar b/examples/mobile/android_example/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index e708b1c023ec8..0000000000000 Binary files a/examples/mobile/android_example/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/examples/mobile/android_example/gradlew b/examples/mobile/android_example/gradlew deleted file mode 100755 index 4f906e0c811fc..0000000000000 --- a/examples/mobile/android_example/gradlew +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" diff --git a/examples/mobile/android_example_native/app/build.gradle b/examples/mobile/android_example_native/app/build.gradle deleted file mode 100644 index 68237739283b6..0000000000000 --- a/examples/mobile/android_example_native/app/build.gradle +++ /dev/null @@ -1,51 +0,0 @@ -plugins { - alias(libs.plugins.android.application) -} - -android { - namespace 'org.bevyengine.example' - compileSdk 34 - - defaultConfig { - applicationId "org.bevyengine.example" - minSdk 31 - targetSdk 33 - versionCode 1 - versionName "1.0" - // set up targets - ndk { - abiFilters 'arm64-v8a' - } - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - buildFeatures { - viewBinding true - } - sourceSets { - main { - assets.srcDirs += files('../../../../assets') - - res.srcDirs += files('../../../../assets/android-res') - } - } -} - -dependencies { - - implementation libs.appcompat - implementation libs.material - implementation libs.constraintlayout - testImplementation libs.junit - androidTestImplementation libs.ext.junit - androidTestImplementation libs.espresso.core -} diff --git a/examples/mobile/android_example_native/app/src/main/AndroidManifest.xml b/examples/mobile/android_example_native/app/src/main/AndroidManifest.xml deleted file mode 100644 index 38861e3924e60..0000000000000 --- a/examples/mobile/android_example_native/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/mobile/android_example_native/app/src/main/java/org/bevyengine/example/MainActivity.java b/examples/mobile/android_example_native/app/src/main/java/org/bevyengine/example/MainActivity.java deleted file mode 100644 index 14d4505228d48..0000000000000 --- a/examples/mobile/android_example_native/app/src/main/java/org/bevyengine/example/MainActivity.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.bevyengine.example; - -import android.view.View; - -import android.app.NativeActivity; - -public class MainActivity extends NativeActivity { - static { - System.loadLibrary("bevy_mobile_example"); - } - - @Override - public void onWindowFocusChanged(boolean hasFocus) { - super.onWindowFocusChanged(hasFocus); - - if (hasFocus) { - hideSystemUi(); - } - } - - private void hideSystemUi() { - View decorView = getWindow().getDecorView(); - decorView.setSystemUiVisibility( - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY - | View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_FULLSCREEN - ); - } - } \ No newline at end of file diff --git a/examples/mobile/android_example_native/build.gradle b/examples/mobile/android_example_native/build.gradle deleted file mode 100644 index 327342f6cd108..0000000000000 --- a/examples/mobile/android_example_native/build.gradle +++ /dev/null @@ -1,4 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -plugins { - alias(libs.plugins.android.application) apply false -} diff --git a/examples/mobile/android_example_native/gradle.properties b/examples/mobile/android_example_native/gradle.properties deleted file mode 100644 index 4387edc225e5d..0000000000000 --- a/examples/mobile/android_example_native/gradle.properties +++ /dev/null @@ -1,21 +0,0 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. For more details, visit -# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Enables namespacing of each library's R class so that its R class includes only the -# resources declared in the library itself and none from the library's dependencies, -# thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file diff --git a/examples/mobile/android_example_native/gradle/libs.versions.toml b/examples/mobile/android_example_native/gradle/libs.versions.toml deleted file mode 100644 index 20540a5893492..0000000000000 --- a/examples/mobile/android_example_native/gradle/libs.versions.toml +++ /dev/null @@ -1,19 +0,0 @@ -[versions] -agp = "8.4.0" -junit = "4.13.2" -junitVersion = "1.1.5" -espressoCore = "3.5.1" -appcompat = "1.6.1" -material = "1.10.0" -constraintlayout = "2.1.4" - -[libraries] -junit = { group = "junit", name = "junit", version.ref = "junit" } -ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } -espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } -appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } -material = { group = "com.google.android.material", name = "material", version.ref = "material" } -constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } - -[plugins] -android-application = { id = "com.android.application", version.ref = "agp" } diff --git a/examples/mobile/android_example_native/gradle/wrapper/gradle-wrapper.jar b/examples/mobile/android_example_native/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index e708b1c023ec8..0000000000000 Binary files a/examples/mobile/android_example_native/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/examples/mobile/android_example_native/gradle/wrapper/gradle-wrapper.properties b/examples/mobile/android_example_native/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 0644b045777b9..0000000000000 --- a/examples/mobile/android_example_native/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Mon May 13 21:19:35 CST 2024 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/examples/mobile/android_example_native/gradlew b/examples/mobile/android_example_native/gradlew deleted file mode 100755 index 4f906e0c811fc..0000000000000 --- a/examples/mobile/android_example_native/gradlew +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" diff --git a/examples/mobile/android_example_native/gradlew.bat b/examples/mobile/android_example_native/gradlew.bat deleted file mode 100644 index ac1b06f93825d..0000000000000 --- a/examples/mobile/android_example_native/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/examples/mobile/android_example_native/settings.gradle b/examples/mobile/android_example_native/settings.gradle deleted file mode 100644 index cc9e80cecf638..0000000000000 --- a/examples/mobile/android_example_native/settings.gradle +++ /dev/null @@ -1,23 +0,0 @@ -pluginManagement { - repositories { - google { - content { - includeGroupByRegex("com\\.android.*") - includeGroupByRegex("com\\.google.*") - includeGroupByRegex("androidx.*") - } - } - mavenCentral() - gradlePluginPortal() - } -} -dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) - repositories { - google() - mavenCentral() - } -} - -rootProject.name = "Bevy Example" -include ':app'