protected override IEnumerable <string> GetAllAvailableAndroidSdks() { var roots = new[] { RegistryEx.CurrentUser, RegistryEx.LocalMachine }; var wow = RegistryEx.Wow64.Key32; var regKey = GetMDRegistryKey(); AndroidLogger.LogInfo("sdk", "Looking for Android SDK.."); // Check for the key the user gave us in the VS/addin options foreach (var root in roots) { if (CheckRegistryKeyForExecutable(root, regKey, MDREG_ANDROID_SDK, wow, "platform-tools", Adb)) { yield return(RegistryEx.GetValueString(root, regKey, MDREG_ANDROID_SDK, wow)); } } // Check for the key written by the Xamarin installer if (CheckRegistryKeyForExecutable(RegistryEx.CurrentUser, XAMARIN_ANDROID_INSTALLER_PATH, XAMARIN_ANDROID_INSTALLER_KEY, wow, "platform-tools", Adb)) { yield return(RegistryEx.GetValueString(RegistryEx.CurrentUser, XAMARIN_ANDROID_INSTALLER_PATH, XAMARIN_ANDROID_INSTALLER_KEY, wow)); } // Check for the key written by the Android SDK installer foreach (var root in roots) { if (CheckRegistryKeyForExecutable(root, ANDROID_INSTALLER_PATH, ANDROID_INSTALLER_KEY, wow, "platform-tools", Adb)) { yield return(RegistryEx.GetValueString(root, ANDROID_INSTALLER_PATH, ANDROID_INSTALLER_KEY, wow)); } } // Check some hardcoded paths for good measure var xamarin_private = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Xamarin", "MonoAndroid", "android-sdk-windows"); var android_default = Path.Combine(OS.ProgramFilesX86, "Android", "android-sdk-windows"); var cdrive_default = @"C:\android-sdk-windows"; if (ValidateAndroidSdkLocation(xamarin_private)) { yield return(xamarin_private); } if (ValidateAndroidSdkLocation(android_default)) { yield return(android_default); } if (ValidateAndroidSdkLocation(cdrive_default)) { yield return(cdrive_default); } }
protected override string GetJavaSdkPath() { // check the user specified path var roots = new[] { RegistryEx.CurrentUser, RegistryEx.LocalMachine }; const RegistryEx.Wow64 wow = RegistryEx.Wow64.Key32; var regKey = GetMDRegistryKey(); foreach (var root in roots) { if (CheckRegistryKeyForExecutable(root, regKey, MDREG_JAVA_SDK, wow, "bin", JarSigner)) { return(RegistryEx.GetValueString(root, regKey, MDREG_JAVA_SDK, wow)); } } string subkey = @"SOFTWARE\JavaSoft\Java Development Kit"; AndroidLogger.LogInfo("sdk", "Looking for Java 6 SDK.."); foreach (var wow64 in new[] { RegistryEx.Wow64.Key32, RegistryEx.Wow64.Key64 }) { string key_name = string.Format(@"{0}\{1}\{2}", "HKLM", subkey, "CurrentVersion"); var currentVersion = RegistryEx.GetValueString(RegistryEx.LocalMachine, subkey, "CurrentVersion", wow64); if (!string.IsNullOrEmpty(currentVersion)) { AndroidLogger.LogInfo("sdk", " Key {0} found.", key_name); // No matter what the CurrentVersion is, look for 1.6 or 1.7 or 1.8 if (CheckRegistryKeyForExecutable(RegistryEx.LocalMachine, subkey + "\\" + "1.6", "JavaHome", wow64, "bin", JarSigner)) { return(RegistryEx.GetValueString(RegistryEx.LocalMachine, subkey + "\\" + "1.6", "JavaHome", wow64)); } if (CheckRegistryKeyForExecutable(RegistryEx.LocalMachine, subkey + "\\" + "1.7", "JavaHome", wow64, "bin", JarSigner)) { return(RegistryEx.GetValueString(RegistryEx.LocalMachine, subkey + "\\" + "1.7", "JavaHome", wow64)); } if (CheckRegistryKeyForExecutable(RegistryEx.LocalMachine, subkey + "\\" + "1.8", "JavaHome", wow64, "bin", JarSigner)) { return(RegistryEx.GetValueString(RegistryEx.LocalMachine, subkey + "\\" + "1.8", "JavaHome", wow64)); } } AndroidLogger.LogInfo("sdk", " Key {0} not found.", key_name); } // We ran out of things to check.. return(null); }
protected override IEnumerable <string> GetAllAvailableAndroidNdks() { var roots = new[] { RegistryEx.CurrentUser, RegistryEx.LocalMachine }; var wow = RegistryEx.Wow64.Key32; var regKey = GetMDRegistryKey(); AndroidLogger.LogInfo("sdk", "Looking for Android NDK.."); // Check for the key the user gave us in the VS/addin options foreach (var root in roots) { if (CheckRegistryKeyForExecutable(root, regKey, MDREG_ANDROID_NDK, wow, ".", NdkStack)) { yield return(RegistryEx.GetValueString(root, regKey, MDREG_ANDROID_NDK, wow)); } } /* * // Check for the key written by the Xamarin installer * if (CheckRegistryKeyForExecutable (RegistryEx.CurrentUser, XAMARIN_ANDROID_INSTALLER_PATH, XAMARIN_ANDROID_INSTALLER_KEY, wow, "platform-tools", Adb)) * yield return RegistryEx.GetValueString (RegistryEx.CurrentUser, XAMARIN_ANDROID_INSTALLER_PATH, XAMARIN_ANDROID_INSTALLER_KEY, wow); */ // Check some hardcoded paths for good measure var xamarin_private = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Xamarin", "MonoAndroid"); var android_default = Path.Combine(OS.ProgramFilesX86, "Android"); var cdrive_default = @"C:\"; foreach (var basePath in new string [] { xamarin_private, android_default, cdrive_default }) { if (Directory.Exists(basePath)) { foreach (var dir in Directory.GetDirectories(basePath, "android-ndk-r*")) { if (ValidateAndroidNdkLocation(dir)) { yield return(dir); } } } } }
private bool CheckRegistryKeyForExecutable(UIntPtr key, string subkey, string valueName, RegistryEx.Wow64 wow64, string subdir, string exe) { string key_name = string.Format(@"{0}\{1}\{2}", key == RegistryEx.CurrentUser ? "HKCU" : "HKLM", subkey, valueName); var path = NullIfEmpty(RegistryEx.GetValueString(key, subkey, valueName, wow64)); if (path == null) { AndroidLogger.LogInfo("sdk", " Key {0} not found.", key_name); return(false); } if (!FindExecutableInDirectory(exe, Path.Combine(path, subdir)).Any()) { AndroidLogger.LogInfo("sdk", " Key {0} found:\n Path does not contain {1} in \\{2} ({3}).", key_name, exe, subdir, path); return(false); } AndroidLogger.LogInfo("sdk", " Key {0} found:\n Path contains {1} in \\{2} ({3}).", key_name, exe, subdir, path); return(true); }
public override void SetPreferredAndroidNdkPath(string path) { RegistryEx.SetValueString(RegistryEx.CurrentUser, MDREG_KEY, MDREG_ANDROID_NDK, path ?? "", RegistryEx.Wow64.Key32); }
public override void SetPreferredJavaSdkPath(string path) { RegistryEx.SetValueString(RegistryEx.CurrentUser, MDREG_KEY, MDREG_JAVA_SDK, path ?? "", RegistryEx.Wow64.Key32); }
private bool CheckRegistryKeyForExecutable(UIntPtr key, string subkey, string valueName, RegistryEx.Wow64 wow64, string subdir, string exe) { string key_name = string.Format (@"{0}\{1}\{2}", key == RegistryEx.CurrentUser ? "HKCU" : "HKLM", subkey, valueName); var path = NullIfEmpty (RegistryEx.GetValueString (key, subkey, valueName, wow64)); if (path == null) { AndroidLogger.LogInfo ("sdk", " Key {0} not found.", key_name); return false; } if (!File.Exists (Path.Combine (path, subdir, exe))) { AndroidLogger.LogInfo ("sdk", " Key {0} found:\n Path does not contain {1} in \\{2} ({3}).", key_name, exe, subdir, path); return false; } AndroidLogger.LogInfo ("sdk", " Key {0} found:\n Path contains {1} in \\{2} ({3}).", key_name, exe, subdir, path); return true; }
public override void SetPreferredAndroidNdkPath(string path) { var regKey = GetMDRegistryKey(); RegistryEx.SetValueString(RegistryEx.CurrentUser, regKey, MDREG_ANDROID_NDK, path ?? "", RegistryEx.Wow64.Key32); }
public override void SetPreferredJavaSdkPath(string path) { var regKey = GetMDRegistryKey(); RegistryEx.SetValueString(RegistryEx.CurrentUser, regKey, MDREG_JAVA_SDK, path ?? "", RegistryEx.Wow64.Key32); }