From 44852467f4fd73214d5b68a577e81ac08ee2daf5 Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Fri, 14 Jun 2024 10:55:46 -0700 Subject: [PATCH] AndroidHelper: report errors for missing adb and emulator executables when they are used only, instead of immediately in AndroidHelper.initialize() It turns out that adb isn't included GitHub Actions unless you install it specifically. However, you can technically build Android apps with Lime without adb, so we shouldn't report the error in initialize(). Most important is install(), where both adb and emulator are commonly used. Followup to eed47e713221bf4a58990aff9cc5ad9c5490b510 --- src/lime/tools/AndroidHelper.hx | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/lime/tools/AndroidHelper.hx b/src/lime/tools/AndroidHelper.hx index d9a0215ae..e93a640bc 100644 --- a/src/lime/tools/AndroidHelper.hx +++ b/src/lime/tools/AndroidHelper.hx @@ -173,23 +173,12 @@ class AndroidHelper { // in older SDKs, adb was located in /tools/ adbPath = project.environment.get("ANDROID_SDK") + "/tools/"; - - // we always need adb, so report an error immediately if it is missing - if (!FileSystem.exists(adbPath + adbName)) - { - Log.error("adb not found in Android SDK: " + project.environment.get("ANDROID_SDK")); - } } if (!FileSystem.exists(emulatorPath + emulatorName)) { // in older SDKs, emulator was located in /tools/ emulatorPath = project.environment.get("ANDROID_SDK") + "/tools/"; - // report an error for missing emulator only if we actually need it - if (!FileSystem.exists(emulatorPath + emulatorName) && (project.targetFlags.exists("emulator") || project.targetFlags.exists("simulator"))) - { - Log.error("emulator not found in Android SDK: " + project.environment.get("ANDROID_SDK")); - } } if (System.hostPlatform != WINDOWS) @@ -206,8 +195,18 @@ class AndroidHelper public static function install(project:HXProject, targetPath:String, deviceID:String = null):String { + if (!FileSystem.exists(adbPath + adbName)) + { + Log.error("adb not found in Android SDK: " + project.environment.get("ANDROID_SDK")); + } + if (project.targetFlags.exists("emulator") || project.targetFlags.exists("simulator")) { + if (!FileSystem.exists(emulatorPath + emulatorName)) + { + Log.error("emulator not found in Android SDK: " + project.environment.get("ANDROID_SDK")); + } + Log.info("", "Searching for Android emulator"); var devices = listDevices(); @@ -352,6 +351,11 @@ class AndroidHelper public static function trace(project:HXProject, debug:Bool, deviceID:String = null, customFilter:String = null):Void { + if (!FileSystem.exists(adbPath + adbName)) + { + Log.error("adb not found in Android SDK: " + project.environment.get("ANDROID_SDK")); + } + // Use -DFULL_LOGCAT or if you do not want to filter log messages var args = ["logcat"]; @@ -404,6 +408,11 @@ class AndroidHelper public static function uninstall(packageName:String, deviceID:String = null):Void { + if (!FileSystem.exists(adbPath + adbName)) + { + Log.error("adb not found in Android SDK"); + } + var args = ["uninstall", packageName]; if (deviceID != null && deviceID != "")