private static List <string> ReadGradleFile(string prefix, string path)
        {
            try
            {
                if (File.Exists(path))
                {
                    return(new List <string>(File.ReadAllLines(path)));
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            var message = "A successful build requires do modifications to " + prefix + " template. " +
                          "But the template is not activated now.";

            Utils.DialogOrCancelBuild(message + "\nClick Сontinue to activate.", BuildTarget.NoTarget);
            try
            {
                if (TryEnableGradleTemplate(path) && File.Exists(path))
                {
                    return(new List <string>(File.ReadAllLines(path)));
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
            Utils.StopBuildWithMessage(message, BuildTarget.NoTarget);
            return(null);
        }
        private static void ConfigureIOS()
        {
#if (UNITY_IOS || CASDeveloper) && !UNITY_2019_3_OR_NEWER
            if (!PlayerSettings.iOS.targetOSVersionString.StartsWith("1"))
            {
                Utils.DialogOrCancelBuild("CAS required a higher minimum deployment target. Set iOS 10.0 and continue?", BuildTarget.NoTarget);
                PlayerSettings.iOS.targetOSVersionString = "10.0";
            }
#endif
        }
        private static void ConfigureAndroid(CASInitSettings settings, CASEditorSettings editorSettings, string admobAppId)
        {
#if UNITY_ANDROID || CASDeveloper
            EditorUtility.DisplayProgressBar(casTitle, "Validate CAS Android Build Settings", 0.8f);

            const string deprecatedPluginPath = "Assets/Plugins/CAS";
            if (AssetDatabase.IsValidFolder(deprecatedPluginPath))
            {
                AssetDatabase.DeleteAsset(deprecatedPluginPath);
                Debug.Log("Removed deprecated plugin: " + deprecatedPluginPath);
            }

            HashSet <string> promoAlias = new HashSet <string>();
            if (editorSettings.generateAndroidQuerriesForPromo)
            {
                for (int i = 0; i < settings.managersCount; i++)
                {
                    Utils.GetCrossPromoAlias(BuildTarget.Android, settings.GetManagerId(i), promoAlias);
                }
            }

            UpdateAndroidPluginManifest(admobAppId, promoAlias, editorSettings);

            CASPreprocessGradle.Configure(editorSettings);

#if !UNITY_2021_2_OR_NEWER
            // 19 - AndroidSdkVersions.AndroidApiLevel19
            // Deprecated in Unity 2021.2
            if (PlayerSettings.Android.minSdkVersion < ( AndroidSdkVersions )19)
            {
                Utils.DialogOrCancelBuild("CAS required a higher minimum SDK API level. Set SDK level 19 (KitKat) and continue?", BuildTarget.NoTarget);
                PlayerSettings.Android.minSdkVersion = ( AndroidSdkVersions )19;
            }
#endif
#endif
        }
        public static void ConfigureProject(BuildTarget target, CASEditorSettings editorSettings)
        {
            if (target != BuildTarget.Android && target != BuildTarget.iOS)
            {
                return;
            }

            var settings = Utils.GetSettingsAsset(target, false);

            if (!settings)
            {
                Utils.StopBuildWithMessage("Settings asset not found. Please use menu Assets > CleverAdsSolutions > Settings " +
                                           "to create and set settings for build.", target);
            }

            var deps = DependencyManager.Create(target, Audience.Mixed, true);

            if (!Application.isBatchMode)
            {
                var newCASVersion = Utils.GetNewVersionOrNull(Utils.gitUnityRepo, MobileAds.wrapperVersion, false);
                if (newCASVersion != null)
                {
                    Utils.DialogOrCancelBuild("There is a new version " + newCASVersion + " of the CAS Unity available for update.", target);
                }

                if (deps != null)
                {
                    if (!deps.installedAny)
                    {
                        Utils.StopBuildWithMessage("Dependencies of native SDK were not found. " +
                                                   "Please use 'Assets > CleverAdsSolutions > Settings' menu to integrate solutions or any SDK separately.", target);
                    }

                    if (deps.IsNewerVersionFound())
                    {
                        Utils.DialogOrCancelBuild("There is a new versions of the native dependencies available for update." +
                                                  "Please use 'Assets > CleverAdsSolutions >Settings' menu to update.", target);
                    }
                }
            }

            if (settings.managersCount == 0 || string.IsNullOrEmpty(settings.GetManagerId(0)))
            {
                StopBuildIDNotFound(target);
            }

            string admobAppId = UpdateRemoteSettingsAndGetAppId(settings, target, deps);

            if (target == BuildTarget.Android)
            {
                ConfigureAndroid(settings, editorSettings, admobAppId);
            }
            else if (target == BuildTarget.iOS)
            {
                ConfigureIOS();
            }

#pragma warning disable CS0618 // Type or member is obsolete
            // Use directrly property to avoid Debug build
            if (settings.testAdMode && !EditorUserBuildSettings.development)
            {
                Debug.LogWarning(Utils.logTag + "Test Ads Mode enabled! Make sure the build is for testing purposes only!\n" +
                                 "Use 'Assets > CleverAdsSolutions > Settings' menu to disable Test Ad Mode.");
            }
            else
            {
                Debug.Log(Utils.logTag + "Project configuration completed");
            }
#pragma warning restore CS0618 // Type or member is obsolete
        }