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

fix: Update to Unity 2022.3.55f1 #1957

Merged
merged 4 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
38 changes: 29 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -463,7 +463,7 @@ jobs:
- unity-version: "2019"
ndk: "r19"
- unity-version: "2022"
ndk: "r21d"
ndk: "r23b"
- unity-version: "6000"
ndk: "r23b"

Expand Down Expand Up @@ -491,6 +491,31 @@ jobs:
ndk-version: ${{ matrix.ndk }}
add-to-path: false

- name: Setup Java for Unity
if: ${{ matrix.platform == 'Android' }}
run: |
switch -Regex ("${{ matrix.unity-version }}")
{
"2019" {
$javaHome = $env:JAVA_HOME_8_X64
Write-Host "Using Java 8 for Unity 2019"
}
"2022" {
$javaHome = "$env:JAVA_HOME_11_X64"
Write-Host "Using Java 11 for Unity 2022"
}
"6000" {
$javaHome = "$env:JAVA_HOME_17_X64"
Write-Host "Using Java 17 for Unity 6"
}
default {
throw "Unexpected Unity version: ${{ matrix.unity-version }}"
}
}

Write-Host "Selected JAVA_HOME: $javaHome"
"JAVA_HOME=$javaHome" >> $env:GITHUB_ENV

# We modify the exported gradle project to deal with the different build-environment
# I.e. we're fixing the paths for SDK & NDK that have been hardcoded to point at the Unity installation
- name: Modify gradle project
Expand All @@ -500,23 +525,18 @@ jobs:
-AndroidSdkRoot $env:ANDROID_SDK_ROOT `
-NdkPath ${{ steps.setup-ndk.outputs.ndk-path }} `
-UnityVersion ${{ matrix.unity-version }}

- name: Setup JDK 17 for Unity 6
if: ${{ matrix.platform == 'Android' && matrix.unity-version == '6000' }}
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Android smoke test
if: ${{ matrix.platform == 'Android' }}
run: ./scripts/smoke-test-android.ps1 Build -IsIntegrationTest -UnityVersion "${{ matrix.unity-version }}"
timeout-minutes: 10
env:
JAVA_HOME: ${{ env.JAVA_HOME }}

- name: iOS smoke test
if: ${{ matrix.platform == 'iOS' }}
run: ./scripts/smoke-test-ios.ps1 Build -IsIntegrationTest -UnityVersion "${{ matrix.unity-version }}"
timeout-minutes: 10

- name: Upload Project project on failure
if: ${{ failure() }}
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci-env.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ switch ($name) {
return "2021.3.45f1"
}
"unity2022" {
return "2022.3.42f1"
return "2022.3.55f1"
}
"unity2023" {
return "2023.2.20f1"
Expand Down
7 changes: 7 additions & 0 deletions test/Scripts.Integration.Test/Editor/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
24 changes: 24 additions & 0 deletions test/Scripts.Integration.Test/modify-gradle-project.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading