From c0a5765da51d120c6164ae3c0466d54b8167aee2 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Tue, 5 Jan 2021 11:56:19 +0000 Subject: [PATCH] utils/android: Fix aapt discovery with unexpected structure If there is an additional file or directory in the `build_tools` directory then WA can fail to find a working version of aapt(2), ensure that at least one of the binaries is a valid file path. --- devlib/utils/android.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/devlib/utils/android.py b/devlib/utils/android.py index d6a9472..7af3145 100755 --- a/devlib/utils/android.py +++ b/devlib/utils/android.py @@ -734,11 +734,13 @@ def _discover_aapt(env): aapt2_path = '' versions = os.listdir(env.build_tools) for version in reversed(sorted(versions)): - if not aapt2_path and not os.path.isfile(aapt2_path): + if not os.path.isfile(aapt2_path): aapt2_path = os.path.join(env.build_tools, version, 'aapt2') - if not aapt_path and not os.path.isfile(aapt_path): + if not os.path.isfile(aapt_path): aapt_path = os.path.join(env.build_tools, version, 'aapt') aapt_version = 1 + # Use latest available version for aapt/appt2 but ensure at least one is valid. + if os.path.isfile(aapt2_path) or os.path.isfile(aapt_path): break # Use aapt2 only if present and we have a suitable version