From 54613dd78e6ff0a0ce373eb1544b2c8e5a0312e3 Mon Sep 17 00:00:00 2001 From: Stefan Jandl Date: Mon, 13 Jan 2025 13:41:00 +0100 Subject: [PATCH] fix: Update to Unity `2022.3.55f1` (#1957) --- .github/workflows/ci.yml | 4 ++-- scripts/ci-env.ps1 | 2 +- .../Editor/Builder.cs | 7 ++++++ .../modify-gradle-project.ps1 | 24 +++++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0757cb2ef..04c5c589d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -452,7 +452,7 @@ jobs: if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} needs: [smoke-test-build] name: ${{ matrix.unity-version }} ${{ matrix.platform }} Compile Smoke Test - runs-on: ${{ matrix.platform == 'iOS' && 'macos' || 'ubuntu' }}-latest + runs-on: ${{ matrix.platform == 'iOS' && 'macos-latest' || 'ubuntu-latest-4-cores' }} strategy: fail-fast: false matrix: @@ -463,7 +463,7 @@ jobs: - unity-version: "2019" ndk: "r19" - unity-version: "2022" - ndk: "r21d" + ndk: "r23b" - unity-version: "6000" ndk: "r23b" diff --git a/scripts/ci-env.ps1 b/scripts/ci-env.ps1 index c35c5abff..8d31a4e0d 100644 --- a/scripts/ci-env.ps1 +++ b/scripts/ci-env.ps1 @@ -14,7 +14,7 @@ switch ($name) { return "2021.3.45f1" } "unity2022" { - return "2022.3.42f1" + return "2022.3.55f1" } "unity2023" { return "2023.2.20f1" diff --git a/test/Scripts.Integration.Test/Editor/Builder.cs b/test/Scripts.Integration.Test/Editor/Builder.cs index 21ed70d51..3c962e036 100644 --- a/test/Scripts.Integration.Test/Editor/Builder.cs +++ b/test/Scripts.Integration.Test/Editor/Builder.cs @@ -34,6 +34,13 @@ public static void BuildIl2CPPPlayer(BuildTarget target, BuildTargetGroup group, EditorUserBuildSettings.il2CppCodeGeneration = UnityEditor.Build.Il2CppCodeGeneration.OptimizeSize; #endif + // This is a workaround for build issues with Unity 2022.3. and newer. + // https://discussions.unity.com/t/gradle-build-issues-for-android-api-sdk-35-in-unity-2022-3lts/1502187/10 +#if UNITY_2022_3_OR_NEWER + Debug.Log("Builder: Setting Android target API level to 33"); + PlayerSettings.Android.targetSdkVersion = AndroidSdkVersions.AndroidApiLevel33; +#endif + Debug.Log("Builder: Updating BuildPlayerOptions"); var buildPlayerOptions = new BuildPlayerOptions { diff --git a/test/Scripts.Integration.Test/modify-gradle-project.ps1 b/test/Scripts.Integration.Test/modify-gradle-project.ps1 index 19d3d88fc..777fa6138 100644 --- a/test/Scripts.Integration.Test/modify-gradle-project.ps1 +++ b/test/Scripts.Integration.Test/modify-gradle-project.ps1 @@ -41,6 +41,30 @@ If ([int]$UnityVersion -ge 2021) } } +# This is a temporary workaround for build issues with Unity 2022.3. and newer. Unity writes an absolute path to the aapt2 in the gradle.properties file. +# This path is not available on the CI runners, so we're replacing it with the one available on the CI runners. +# https://discussions.unity.com/t/gradle-build-issues-for-android-api-sdk-35-in-unity-2022-3lts/1502187/10 +If ([int]$UnityVersion -eq 2022) +{ + Write-Output "Updating aapt2 path." + + $gradlePropertiesFile = Join-Path -Path $workingDirectory -ChildPath "gradle.properties" + $fileContent = Get-Content -Path $gradlePropertiesFile + + $aapt2Path = "$androidSdkRoot/build-tools/34.0.0/aapt2" + if (Test-Path $aapt2Path) + { + Write-Output "Setting the aapt2 path to: $aapt2Path" + + $updatedContent = $fileContent -replace '/opt/unity/Editor/Data/PlaybackEngines/AndroidPlayer/SDK/build-tools/34.0.0/aapt2', $aapt2Path + $updatedContent | Set-Content -Path $gradlePropertiesFile + } + else + { + Write-Output "aapt2 not found at: $aapt2Path" + } +} + # Starting with Unity 6 the paths to SDK, NDK, and JDK are written to the `gradle.properties` # We're removing it to cause it to fall back to the local.properties If ([int]$UnityVersion -ge 6000)