Beispiel #1
0
        public AndroidSdkInfo(Action <TraceLevel, string> logger = null, string androidSdkPath = null, string androidNdkPath = null, string javaSdkPath = null)
        {
            logger = logger ?? DefaultConsoleLogger;

            sdk = CreateSdk(logger);
            sdk.Initialize(androidSdkPath, androidNdkPath, javaSdkPath);

            // shouldn't happen, in that sdk.Initialize() should throw instead
            if (string.IsNullOrEmpty(AndroidSdkPath))
            {
                throw new InvalidOperationException($"Could not determine Android SDK location. Please provide `{nameof (androidSdkPath)}`.");
            }
            if (string.IsNullOrEmpty(JavaSdkPath))
            {
                throw new InvalidOperationException($"Could not determine Java SDK location. Please provide `{nameof (javaSdkPath)}`.");
            }
        }
Beispiel #2
0
        internal static bool CheckRegistryKeyForExecutable(UIntPtr key, string subkey, string valueName, RegistryEx.Wow64 wow64, string subdir, string exe)
        {
            try {
                string key_name = string.Format(@"{0}\{1}\{2}", key == RegistryEx.CurrentUser ? "HKCU" : "HKLM", subkey, valueName);

                var path = AndroidSdkBase.NullIfEmpty(RegistryEx.GetValueString(key, subkey, valueName, wow64));

                if (path == null)
                {
                    return(false);
                }

                if (!ProcessUtils.FindExecutablesInDirectory(Path.Combine(path, subdir), exe).Any())
                {
                    return(false);
                }

                return(true);
            } catch (Exception) {
                return(false);
            }
        }
Beispiel #3
0
        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);
            }
        }