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 eed47e7132
This commit is contained in:
@@ -173,23 +173,12 @@ class AndroidHelper
|
|||||||
{
|
{
|
||||||
// in older SDKs, adb was located in /tools/
|
// in older SDKs, adb was located in /tools/
|
||||||
adbPath = project.environment.get("ANDROID_SDK") + "/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))
|
if (!FileSystem.exists(emulatorPath + emulatorName))
|
||||||
{
|
{
|
||||||
// in older SDKs, emulator was located in /tools/
|
// in older SDKs, emulator was located in /tools/
|
||||||
emulatorPath = project.environment.get("ANDROID_SDK") + "/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)
|
if (System.hostPlatform != WINDOWS)
|
||||||
@@ -206,8 +195,18 @@ class AndroidHelper
|
|||||||
|
|
||||||
public static function install(project:HXProject, targetPath:String, deviceID:String = null):String
|
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 (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");
|
Log.info("", "Searching for Android emulator");
|
||||||
|
|
||||||
var devices = listDevices();
|
var devices = listDevices();
|
||||||
@@ -352,6 +351,11 @@ class AndroidHelper
|
|||||||
|
|
||||||
public static function trace(project:HXProject, debug:Bool, deviceID:String = null, customFilter:String = null):Void
|
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 <set name="FULL_LOGCAT" /> if you do not want to filter log messages
|
// Use -DFULL_LOGCAT or <set name="FULL_LOGCAT" /> if you do not want to filter log messages
|
||||||
|
|
||||||
var args = ["logcat"];
|
var args = ["logcat"];
|
||||||
@@ -404,6 +408,11 @@ class AndroidHelper
|
|||||||
|
|
||||||
public static function uninstall(packageName:String, deviceID:String = null):Void
|
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];
|
var args = ["uninstall", packageName];
|
||||||
|
|
||||||
if (deviceID != null && deviceID != "")
|
if (deviceID != null && deviceID != "")
|
||||||
|
|||||||
Reference in New Issue
Block a user