Exemple #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)}`.");
            }
        }
Exemple #2
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);
            }
        }