internal static int GetManifestVersion(string file) { // It seems that MfA 1.0 on Windows didn't include the xml files to get the runtime version. if (!File.Exists(file)) { return(int.MaxValue); } try { using (var r = XmlReader.Create(file, GetSafeReaderSettings())) { if (r.MoveToContent() == XmlNodeType.Element && r.MoveToAttribute("android:versionCode")) { int value; if (int.TryParse(r.Value, out value)) { return(value); } AndroidLogger.LogInfo("Cannot parse runtime version code: ({0})", r.Value); } } } catch (Exception ex) { AndroidLogger.LogError("Error trying to find shared runtime version", ex); } return(int.MaxValue); }
public static void Refresh(string runtimePath = null, string binPath = null, string bclPath = null) { if (OS.IsWindows) { sdk = new MonoDroidSdkWindows(); } else { sdk = new MonoDroidSdkUnix(); } try { sdk.Initialize(runtimePath, binPath, bclPath); } catch (Exception ex) { AndroidLogger.LogError("Error finding Xamarin.Android SDK", ex); } }
private static XDocument GetUnixConfigFile() { var file = UnixConfigPath; XDocument doc = null; if (!File.Exists(file)) { string dir = Path.GetDirectoryName(file); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } } else { try { doc = XDocument.Load(file); } catch (Exception ex) { AndroidLogger.LogError("Could not load monodroid configuration file", ex); // move out of the way and create a new one doc = new XDocument(new XElement("monodroid")); var newFileName = file + ".old"; if (File.Exists(newFileName)) { File.Delete(newFileName); } File.Move(file, newFileName); } } if (doc == null || doc.Root == null) { doc = new XDocument(new XElement("monodroid")); } return(doc); }
public static void Refresh(string androidSdkPath = null, string androidNdkPath = null, string javaSdkPath = null) { if (OS.IsWindows) { sdk = new AndroidSdkWindows(); } else { sdk = new AndroidSdkUnix(); } try { sdk.Initialize(androidSdkPath ?? sdk.PreferedAndroidSdkPath, androidNdkPath ?? sdk.PreferedAndroidNdkPath, javaSdkPath ?? sdk.PreferedJavaSdkPath); if (IsInstalled) { var levels = GetInstalledPlatformVersions().Select(l => l.ApiLevel.ToString()).ToArray(); string levelList; if (levels == null || levels.Length == 0) { levelList = "(none)"; } else { levelList = string.Join(", ", levels); } AndroidLogger.LogInfo(null, "Found Android SDK. API levels: {0}", levelList); } else { AndroidLogger.LogInfo(null, "Did not find Android SDK"); } } catch (Exception ex) { AndroidLogger.LogError("Error finding Android/Java SDKs", ex); } }