From 7a0abbbd741e58de60bf4f04da00683bc21a3a5d Mon Sep 17 00:00:00 2001 From: "almostmatt@google.com" Date: Thu, 19 Jan 2023 14:02:15 -0500 Subject: [PATCH 1/2] Debug the uninstallation of android 33 --- scripts/gha/build_testapps.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/scripts/gha/build_testapps.py b/scripts/gha/build_testapps.py index 0a4d32d8..2c29b845 100644 --- a/scripts/gha/build_testapps.py +++ b/scripts/gha/build_testapps.py @@ -536,20 +536,42 @@ def patch_android_env(unity_version): try: # This is a bug from Unity: # https://issuetracker.unity3d.com/issues/android-android-build-fails-when-targeting-sdk-31-and-using-build-tools-31-dot-0-0 - _run([sdkmanager_path, "--uninstall", "build-tools;31.0.0"], check=False) + _run([sdkmanager_path, "--uninstall", "build-tools;31.0.0"], check=True) logging.info("Uninstall Android build tool 31.0.0") except Exception as e: logging.info(str(e)) + # check if android 33 is intalled + logging.info("Checking for platforms;android-33") + _run([sdkmanager_path, "--list_installed"], check=True) + try: # The platform android-33 includes libraries that were built with Java 11, and require a newer version of gradle # than Unity comes with. Note this only happens when using minification. # If this continues to be a problem, this logic might need to be smarter, to remove all versions newer than 32, # but currently the GitHub runners have 33 as their max. logging.info("Uninstall Android platform android-33") - _run([sdkmanager_path, "--uninstall", "platforms;android-33"], check=False) + _run([sdkmanager_path, "--uninstall", "platforms;android-33"], check=True) except Exception as e: logging.exception("Failed to uninstall Android platform android-33") + + # after single uninstall, check if android 33 is intalled + logging.info("Checking for platforms;android-33") + _run([sdkmanager_path, "--list_installed"], check=True) + + try: + # The platform android-33 includes libraries that were built with Java 11, and require a newer version of gradle + # than Unity comes with. Note this only happens when using minification. + # If this continues to be a problem, this logic might need to be smarter, to remove all versions newer than 32, + # but currently the GitHub runners have 33 as their max. + logging.info("Uninstall Android platform android-33-ext4") + _run([sdkmanager_path, "--uninstall", "platforms;android-33-ext4"], check=True) + except Exception as e: + logging.exception("Failed to uninstall Android platform android-33-ext4") + + # after uninstalls, check if android 33 is intalled + logging.info("Checking for platforms;android-33") + _run([sdkmanager_path, "--list_installed"], check=True) os.environ["UNITY_ANDROID_SDK"]=os.environ["ANDROID_HOME"] os.environ["UNITY_ANDROID_NDK"]=os.environ["ANDROID_NDK_HOME"] From a2f13dccd29e841a12201520521329ce779ccf6e Mon Sep 17 00:00:00 2001 From: "almostmatt@google.com" Date: Thu, 19 Jan 2023 14:53:25 -0500 Subject: [PATCH 2/2] simplify the script a bit --- scripts/gha/build_testapps.py | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/scripts/gha/build_testapps.py b/scripts/gha/build_testapps.py index 2c29b845..58c08cc1 100644 --- a/scripts/gha/build_testapps.py +++ b/scripts/gha/build_testapps.py @@ -536,43 +536,28 @@ def patch_android_env(unity_version): try: # This is a bug from Unity: # https://issuetracker.unity3d.com/issues/android-android-build-fails-when-targeting-sdk-31-and-using-build-tools-31-dot-0-0 - _run([sdkmanager_path, "--uninstall", "build-tools;31.0.0"], check=True) + _run([sdkmanager_path, "--uninstall", "build-tools;31.0.0"], check=False) logging.info("Uninstall Android build tool 31.0.0") except Exception as e: logging.info(str(e)) - # check if android 33 is intalled - logging.info("Checking for platforms;android-33") - _run([sdkmanager_path, "--list_installed"], check=True) - try: # The platform android-33 includes libraries that were built with Java 11, and require a newer version of gradle # than Unity comes with. Note this only happens when using minification. # If this continues to be a problem, this logic might need to be smarter, to remove all versions newer than 32, # but currently the GitHub runners have 33 as their max. logging.info("Uninstall Android platform android-33") - _run([sdkmanager_path, "--uninstall", "platforms;android-33"], check=True) + _run([sdkmanager_path, "--uninstall", "platforms;android-33", "platforms;android-33-ext4"], check=False) except Exception as e: logging.exception("Failed to uninstall Android platform android-33") - # after single uninstall, check if android 33 is intalled - logging.info("Checking for platforms;android-33") - _run([sdkmanager_path, "--list_installed"], check=True) - try: - # The platform android-33 includes libraries that were built with Java 11, and require a newer version of gradle - # than Unity comes with. Note this only happens when using minification. - # If this continues to be a problem, this logic might need to be smarter, to remove all versions newer than 32, - # but currently the GitHub runners have 33 as their max. - logging.info("Uninstall Android platform android-33-ext4") - _run([sdkmanager_path, "--uninstall", "platforms;android-33-ext4"], check=True) + # List the installed packages to make it easier to notice if any incompatible packages are present. + logging.info("Listing installed sdks") + _run([sdkmanager_path, "--list_installed"], check=False) except Exception as e: - logging.exception("Failed to uninstall Android platform android-33-ext4") - - # after uninstalls, check if android 33 is intalled - logging.info("Checking for platforms;android-33") - _run([sdkmanager_path, "--list_installed"], check=True) - + logging.info(str(e)) + os.environ["UNITY_ANDROID_SDK"]=os.environ["ANDROID_HOME"] os.environ["UNITY_ANDROID_NDK"]=os.environ["ANDROID_NDK_HOME"] os.environ["UNITY_ANDROID_JDK"]=os.environ["JAVA_HOME"]