Skip to content

Commit 5b85919

Browse files
committed
fix: Use minSdk 26 and correct minSdk for GameActivity
This also fixes a nullpointer exception in hideSystemUi that has been observed on Android API 28 (Samsung Galaxy J3)
1 parent efab415 commit 5b85919

4 files changed

Lines changed: 17 additions & 34 deletions

File tree

docs-template/EXAMPLE_README.md.tpl

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ adb uninstall org.bevyengine.example
193193

194194
**⚠️ Note:** If you are using `bevy_audio` the minimum supported Android API version is 26 (Android 8/Oreo).
195195

196-
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).
196+
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 26 as `minSdk`. This approach is recommended in the [Android Developers documentation](https://developer.android.com/google/play/requirements/target-sdk#why-target).
197197

198-
Bevy uses [`GameActivity`](https://developer.android.com/games/agdk/game-activity), which only works for Android API 31 and higher. If you want to use an older API, you need to switch to [`NativeActivity`](https://developer.android.com/reference/android/app/NativeActivity).
198+
Bevy uses [`GameActivity`](https://developer.android.com/games/agdk/game-activity), which only works for Android API 23 and higher. If you want to use an older API, you need to switch to [`NativeActivity`](https://developer.android.com/reference/android/app/NativeActivity).
199199

200200
You can follow the following steps to switch from [`GameActivity`](https://developer.android.com/games/agdk/game-activity) to [`NativeActivity`](https://developer.android.com/reference/android/app/NativeActivity):
201201

@@ -263,27 +263,18 @@ You can follow the following steps to switch from [`GameActivity`](https://devel
263263
```
264264

265265
</details>
266-
3. Change `minSdk` (optional) and remove unnecessary dependencies in `android/app/build.gradle.kts`.
266+
3. Remove unnecessary dependencies in `android/app/build.gradle.kts`.
267267
<details>
268268
<summary>Required Changes (Example)</summary>
269269

270270
```diff
271271
--- a/examples/mobile/android/app/build.gradle.kts
272-
+++ b/examples/mobile/android/app/build.gradle.kts
273-
defaultConfig {
274-
applicationId = "org.bevyengine.example"
275-
- minSdk = 31
276-
+ minSdk = 26
277-
targetSdk = 36
278-
// NOTE: Increase by 1 on each release
279-
versionCode = 1
280-
--- a/examples/mobile/android/app/build.gradle.kts
281272
+++ b/examples/mobile/android/app/build.gradle.kts
282273
dependencies {
283274
implementation(libs.appcompat)
284275
implementation(libs.core)
285276
implementation(libs.material)
286-
- implementation(libs.games.activity)
277+
- implementation(libs.games.activity)
287278
implementation(libs.core.ktx)
288279
}
289280
```

examples/README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -801,9 +801,9 @@ adb uninstall org.bevyengine.example
801801

802802
**⚠️ Note:** If you are using `bevy_audio` the minimum supported Android API version is 26 (Android 8/Oreo).
803803

804-
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).
804+
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 26 as `minSdk`. This approach is recommended in the [Android Developers documentation](https://developer.android.com/google/play/requirements/target-sdk#why-target).
805805

806-
Bevy uses [`GameActivity`](https://developer.android.com/games/agdk/game-activity), which only works for Android API 31 and higher. If you want to use an older API, you need to switch to [`NativeActivity`](https://developer.android.com/reference/android/app/NativeActivity).
806+
Bevy uses [`GameActivity`](https://developer.android.com/games/agdk/game-activity), which only works for Android API 23 and higher. If you want to use an older API, you need to switch to [`NativeActivity`](https://developer.android.com/reference/android/app/NativeActivity).
807807

808808
You can follow the following steps to switch from [`GameActivity`](https://developer.android.com/games/agdk/game-activity) to [`NativeActivity`](https://developer.android.com/reference/android/app/NativeActivity):
809809

@@ -871,27 +871,18 @@ You can follow the following steps to switch from [`GameActivity`](https://devel
871871
```
872872
873873
</details>
874-
3. Change `minSdk` (optional) and remove unnecessary dependencies in `android/app/build.gradle.kts`.
874+
3. Remove unnecessary dependencies in `android/app/build.gradle.kts`.
875875
<details>
876876
<summary>Required Changes (Example)</summary>
877877
878878
```diff
879879
--- a/examples/mobile/android/app/build.gradle.kts
880-
+++ b/examples/mobile/android/app/build.gradle.kts
881-
defaultConfig {
882-
applicationId = "org.bevyengine.example"
883-
- minSdk = 31
884-
+ minSdk = 26
885-
targetSdk = 36
886-
// NOTE: Increase by 1 on each release
887-
versionCode = 1
888-
--- a/examples/mobile/android/app/build.gradle.kts
889880
+++ b/examples/mobile/android/app/build.gradle.kts
890881
dependencies {
891882
implementation(libs.appcompat)
892883
implementation(libs.core)
893884
implementation(libs.material)
894-
- implementation(libs.games.activity)
885+
- implementation(libs.games.activity)
895886
implementation(libs.core.ktx)
896887
}
897888
```

examples/mobile/android/app/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ android {
2424
// https://developer.android.com/reference/tools/gradle-api/9.1/com/android/build/api/dsl/DefaultConfig
2525
defaultConfig {
2626
applicationId = "org.bevyengine.example"
27-
minSdk = 31
27+
// NOTE: `minSdk` is 26 because this is the minimum supported by `bevy_audio`
28+
minSdk = 26
2829
targetSdk = 36
2930
// NOTE: Increase by 1 on each release
3031
versionCode = 1

examples/mobile/android/app/src/main/kotlin/org/bevyengine/example/MainActivity.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ class MainActivity : GameActivity() {
4242
* Hide system UI.
4343
*/
4444
private fun hideSystemUi() {
45-
val windowInsetsController =
46-
WindowCompat.getInsetsController(window, window.decorView)
47-
48-
// Show bars if swiping
49-
windowInsetsController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
50-
// Hide both the status bar and the navigation bar.
51-
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
45+
window.decorView.post {
46+
val controller = WindowCompat.getInsetsController(window, window.decorView)
47+
// Show bars if swiping
48+
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
49+
// Hide both the status bar and the navigation bar.
50+
controller.hide(WindowInsetsCompat.Type.systemBars())
51+
}
5252
}
5353

5454
companion object {

0 commit comments

Comments
 (0)