public override bool Execute() { var dirs = string.IsNullOrEmpty(ToolPath) ? null : new [] { ToolPath }; var path = Which.GetProgramLocation(ToolExe ?? ToolName, out var filename, dirs); if (path == null) { Log.LogError($"Could not find `avdmanager`. Please set the `{nameof (CreateAndroidEmulator)}.{nameof (ToolPath)}` property appropriately."); return(false); } ToolExe = filename; if (string.IsNullOrEmpty(TargetId) && !string.IsNullOrEmpty(SdkVersion)) { TargetId = "system-images;android-" + SdkVersion + ";default;" + AndroidAbi; } var env = new List <string> (); env.Add($"ANDROID_PREFS_ROOT={AvdManagerHome}"); if (!string.IsNullOrEmpty(JavaSdkHome)) { env.Add($"JAVA_HOME={JavaSdkHome}"); } EnvironmentVariables = env.ToArray(); base.Execute(); if (Log.HasLoggedErrors) { return(false); } var configPath = Path.Combine(AvdManagerHome, ".android", "avd", $"{ImageName}.avd", "config.ini"); if (File.Exists(configPath)) { Log.LogMessage($"Config file for AVD '{ImageName}' found at {configPath}"); WriteConfigFile(configPath); return(!Log.HasLoggedErrors); } Log.LogWarning($"AVD '{ImageName}' will use default emulator settings (memory and data partition size)"); return(!Log.HasLoggedErrors); }
string GetAndroidPath () { if (string.IsNullOrEmpty (ToolExe)) ToolExe = "avdmanager"; var dirs = string.IsNullOrEmpty (ToolPath) ? null : new [] { ToolPath }; string filename; var path = Which.GetProgramLocation (ToolExe, out filename, dirs); if (path == null) { Log.LogError ($"Could not find `avdmanager`. Please set the `{nameof (CreateAndroidEmulator)}.{nameof (ToolPath)}` property appropriately."); return null; } return path; }
string GetEmulatorPath() { if (string.IsNullOrEmpty(ToolExe)) { ToolExe = "emulator"; } var dirs = string.IsNullOrEmpty(ToolPath) ? null : new [] { ToolPath }; string filename; var path = Which.GetProgramLocation(ToolExe, out filename, dirs); if (path == null) { Log.LogError($"Could not find `emulator`. Please set the `{nameof (StartAndroidEmulator)}.{nameof (ToolExe)}` property appropriately."); return(null); } return(path); }