diff --git a/Assets/Editor/BFBuildProjectTools/Utils/BuildAndroidUtils.cs b/Assets/Editor/BFBuildProjectTools/Utils/BuildAndroidUtils.cs index 4b01307f6..17e56f1b7 100644 --- a/Assets/Editor/BFBuildProjectTools/Utils/BuildAndroidUtils.cs +++ b/Assets/Editor/BFBuildProjectTools/Utils/BuildAndroidUtils.cs @@ -410,7 +410,7 @@ namespace BFEditor.Build var gradleFilePath2 = Path.Combine(PublishAsProjectPath, "unityLibrary", "build.gradle"); var text2 = File.ReadAllText(gradleFilePath2); text2 = regex.Replace(text2, string.Format("versionCode {0}", versionCode)); - text2 = regex2.Replace(text, string.Format("versionName '{0}'", versionName)); + text2 = regex2.Replace(text2, string.Format("versionName '{0}'", versionName)); File.WriteAllText(gradleFilePath2, text2); } diff --git a/Assets/ThirdParty/MaxSdk/Scripts/Editor/MaxPostProcessBuildAndroid.cs b/Assets/ThirdParty/MaxSdk/Scripts/Editor/MaxPostProcessBuildAndroid.cs index 8ad8aee9c..9b719383f 100644 --- a/Assets/ThirdParty/MaxSdk/Scripts/Editor/MaxPostProcessBuildAndroid.cs +++ b/Assets/ThirdParty/MaxSdk/Scripts/Editor/MaxPostProcessBuildAndroid.cs @@ -23,250 +23,250 @@ namespace AppLovinMax.Scripts.Editor /// /// A post processor used to update the Android project once it is generated. /// - public class MaxPostProcessBuildAndroid : IPostGenerateGradleAndroidProject - { -#if UNITY_2019_3_OR_NEWER - private const string PropertyAndroidX = "android.useAndroidX"; - private const string PropertyJetifier = "android.enableJetifier"; - private const string EnableProperty = "=true"; -#endif - private const string PropertyDexingArtifactTransform = "android.enableDexingArtifactTransform"; - private const string DisableProperty = "=false"; +// public class MaxPostProcessBuildAndroid : IPostGenerateGradleAndroidProject +// { +// #if UNITY_2019_3_OR_NEWER +// private const string PropertyAndroidX = "android.useAndroidX"; +// private const string PropertyJetifier = "android.enableJetifier"; +// private const string EnableProperty = "=true"; +// #endif +// private const string PropertyDexingArtifactTransform = "android.enableDexingArtifactTransform"; +// private const string DisableProperty = "=false"; - private const string KeyMetaDataAppLovinSdkKey = "applovin.sdk.key"; - private const string KeyMetaDataAppLovinVerboseLoggingOn = "applovin.sdk.verbose_logging"; - private const string KeyMetaDataGoogleApplicationId = "com.google.android.gms.ads.APPLICATION_ID"; - private const string KeyMetaDataGoogleAdManagerApp = "com.google.android.gms.ads.AD_MANAGER_APP"; +// private const string KeyMetaDataAppLovinSdkKey = "applovin.sdk.key"; +// private const string KeyMetaDataAppLovinVerboseLoggingOn = "applovin.sdk.verbose_logging"; +// private const string KeyMetaDataGoogleApplicationId = "com.google.android.gms.ads.APPLICATION_ID"; +// private const string KeyMetaDataGoogleAdManagerApp = "com.google.android.gms.ads.AD_MANAGER_APP"; - private static readonly XNamespace AndroidNamespace = "http://schemas.android.com/apk/res/android"; +// private static readonly XNamespace AndroidNamespace = "http://schemas.android.com/apk/res/android"; - private static string PluginMediationDirectory - { - get - { - var pluginParentDir = AppLovinIntegrationManager.MediationSpecificPluginParentDirectory; - return Path.Combine(pluginParentDir, "MaxSdk/Mediation/"); - } - } +// private static string PluginMediationDirectory +// { +// get +// { +// var pluginParentDir = AppLovinIntegrationManager.MediationSpecificPluginParentDirectory; +// return Path.Combine(pluginParentDir, "MaxSdk/Mediation/"); +// } +// } - public void OnPostGenerateGradleAndroidProject(string path) - { -#if UNITY_2019_3_OR_NEWER - var gradlePropertiesPath = Path.Combine(path, "../gradle.properties"); -#else - var gradlePropertiesPath = Path.Combine(path, "gradle.properties"); -#endif - var gradlePropertiesUpdated = new List(); +// public void OnPostGenerateGradleAndroidProject(string path) +// { +// #if UNITY_2019_3_OR_NEWER +// var gradlePropertiesPath = Path.Combine(path, "../gradle.properties"); +// #else +// var gradlePropertiesPath = Path.Combine(path, "gradle.properties"); +// #endif +// var gradlePropertiesUpdated = new List(); - // If the gradle properties file already exists, make sure to add any previous properties. - if (File.Exists(gradlePropertiesPath)) - { - var lines = File.ReadAllLines(gradlePropertiesPath); +// // If the gradle properties file already exists, make sure to add any previous properties. +// if (File.Exists(gradlePropertiesPath)) +// { +// var lines = File.ReadAllLines(gradlePropertiesPath); -#if UNITY_2019_3_OR_NEWER - // Add all properties except AndroidX, Jetifier, and DexingArtifactTransform since they may already exist. We will re-add them below. - gradlePropertiesUpdated.AddRange(lines.Where(line => !line.Contains(PropertyAndroidX) && !line.Contains(PropertyJetifier) && !line.Contains(PropertyDexingArtifactTransform))); -#else - // Add all properties except DexingArtifactTransform since it may already exist. We will re-add it below. - gradlePropertiesUpdated.AddRange(lines.Where(line => !line.Contains(PropertyDexingArtifactTransform))); -#endif - } +// #if UNITY_2019_3_OR_NEWER +// // Add all properties except AndroidX, Jetifier, and DexingArtifactTransform since they may already exist. We will re-add them below. +// gradlePropertiesUpdated.AddRange(lines.Where(line => !line.Contains(PropertyAndroidX) && !line.Contains(PropertyJetifier) && !line.Contains(PropertyDexingArtifactTransform))); +// #else +// // Add all properties except DexingArtifactTransform since it may already exist. We will re-add it below. +// gradlePropertiesUpdated.AddRange(lines.Where(line => !line.Contains(PropertyDexingArtifactTransform))); +// #endif +// } -#if UNITY_2019_3_OR_NEWER - // Enable AndroidX and Jetifier properties - gradlePropertiesUpdated.Add(PropertyAndroidX + EnableProperty); - gradlePropertiesUpdated.Add(PropertyJetifier + EnableProperty); -#endif - // Disable dexing using artifact transform (it causes issues for ExoPlayer with Gradle plugin 3.5.0+) - gradlePropertiesUpdated.Add(PropertyDexingArtifactTransform + DisableProperty); +// #if UNITY_2019_3_OR_NEWER +// // Enable AndroidX and Jetifier properties +// gradlePropertiesUpdated.Add(PropertyAndroidX + EnableProperty); +// gradlePropertiesUpdated.Add(PropertyJetifier + EnableProperty); +// #endif +// // Disable dexing using artifact transform (it causes issues for ExoPlayer with Gradle plugin 3.5.0+) +// gradlePropertiesUpdated.Add(PropertyDexingArtifactTransform + DisableProperty); - try - { - File.WriteAllText(gradlePropertiesPath, string.Join("\n", gradlePropertiesUpdated.ToArray()) + "\n"); - } - catch (Exception exception) - { - MaxSdkLogger.UserError("Failed to enable AndroidX and Jetifier. gradle.properties file write failed."); - Console.WriteLine(exception); - } +// try +// { +// File.WriteAllText(gradlePropertiesPath, string.Join("\n", gradlePropertiesUpdated.ToArray()) + "\n"); +// } +// catch (Exception exception) +// { +// MaxSdkLogger.UserError("Failed to enable AndroidX and Jetifier. gradle.properties file write failed."); +// Console.WriteLine(exception); +// } - ProcessAndroidManifest(path); +// ProcessAndroidManifest(path); - var rawResourceDirectory = Path.Combine(path, "src/main/res/raw"); - if (AppLovinSettings.Instance.ShowInternalSettingsInIntegrationManager) - { - // For Unity 2018.1 or older, the consent flow is enabled in AppLovinPreProcessAndroid. - AppLovinPreProcessAndroid.EnableConsentFlowIfNeeded(rawResourceDirectory); - } - else - { - AppLovinPreProcessAndroid.EnableTermsFlowIfNeeded(rawResourceDirectory); - } - } +// var rawResourceDirectory = Path.Combine(path, "src/main/res/raw"); +// if (AppLovinSettings.Instance.ShowInternalSettingsInIntegrationManager) +// { +// // For Unity 2018.1 or older, the consent flow is enabled in AppLovinPreProcessAndroid. +// AppLovinPreProcessAndroid.EnableConsentFlowIfNeeded(rawResourceDirectory); +// } +// else +// { +// AppLovinPreProcessAndroid.EnableTermsFlowIfNeeded(rawResourceDirectory); +// } +// } - public int callbackOrder - { - get { return int.MaxValue; } - } +// public int callbackOrder +// { +// get { return int.MaxValue; } +// } - private static void ProcessAndroidManifest(string path) - { - var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml"); - XDocument manifest; - try - { - manifest = XDocument.Load(manifestPath); - } -#pragma warning disable 0168 - catch (IOException exception) -#pragma warning restore 0168 - { - MaxSdkLogger.UserWarning("[AppLovin MAX] AndroidManifest.xml is missing."); - return; - } +// private static void ProcessAndroidManifest(string path) +// { +// var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml"); +// XDocument manifest; +// try +// { +// manifest = XDocument.Load(manifestPath); +// } +// #pragma warning disable 0168 +// catch (IOException exception) +// #pragma warning restore 0168 +// { +// MaxSdkLogger.UserWarning("[AppLovin MAX] AndroidManifest.xml is missing."); +// return; +// } - // Get the `manifest` element. - var elementManifest = manifest.Element("manifest"); - if (elementManifest == null) - { - MaxSdkLogger.UserWarning("[AppLovin MAX] AndroidManifest.xml is invalid."); - return; - } +// // Get the `manifest` element. +// var elementManifest = manifest.Element("manifest"); +// if (elementManifest == null) +// { +// MaxSdkLogger.UserWarning("[AppLovin MAX] AndroidManifest.xml is invalid."); +// return; +// } - var elementApplication = elementManifest.Element("application"); - if (elementApplication == null) - { - MaxSdkLogger.UserWarning("[AppLovin MAX] AndroidManifest.xml is invalid."); - return; - } +// var elementApplication = elementManifest.Element("application"); +// if (elementApplication == null) +// { +// MaxSdkLogger.UserWarning("[AppLovin MAX] AndroidManifest.xml is invalid."); +// return; +// } - var metaDataElements = elementApplication.Descendants().Where(element => element.Name.LocalName.Equals("meta-data")); +// var metaDataElements = elementApplication.Descendants().Where(element => element.Name.LocalName.Equals("meta-data")); - AddSdkKeyIfNeeded(elementApplication); - EnableVerboseLoggingIfNeeded(elementApplication); - AddGoogleApplicationIdIfNeeded(elementApplication, metaDataElements); +// AddSdkKeyIfNeeded(elementApplication); +// EnableVerboseLoggingIfNeeded(elementApplication); +// AddGoogleApplicationIdIfNeeded(elementApplication, metaDataElements); - // Save the updated manifest file. - manifest.Save(manifestPath); - } +// // Save the updated manifest file. +// manifest.Save(manifestPath); +// } - private static void AddSdkKeyIfNeeded(XElement elementApplication) - { - var sdkKey = AppLovinSettings.Instance.SdkKey; - if (string.IsNullOrEmpty(sdkKey)) return; +// private static void AddSdkKeyIfNeeded(XElement elementApplication) +// { +// var sdkKey = AppLovinSettings.Instance.SdkKey; +// if (string.IsNullOrEmpty(sdkKey)) return; - var descendants = elementApplication.Descendants(); - var sdkKeyMetaData = descendants.FirstOrDefault(descendant => descendant.FirstAttribute != null && - descendant.FirstAttribute.Name.LocalName.Equals("name") && - descendant.FirstAttribute.Value.Equals(KeyMetaDataAppLovinSdkKey) && - descendant.LastAttribute != null && - descendant.LastAttribute.Name.LocalName.Equals("value")); +// var descendants = elementApplication.Descendants(); +// var sdkKeyMetaData = descendants.FirstOrDefault(descendant => descendant.FirstAttribute != null && +// descendant.FirstAttribute.Name.LocalName.Equals("name") && +// descendant.FirstAttribute.Value.Equals(KeyMetaDataAppLovinSdkKey) && +// descendant.LastAttribute != null && +// descendant.LastAttribute.Name.LocalName.Equals("value")); - // check if applovin.sdk.key meta data exists. - if (sdkKeyMetaData != null) - { - sdkKeyMetaData.LastAttribute.Value = sdkKey; - } - else - { - // add applovin.sdk.key meta data if it does not exist. - var metaData = CreateMetaDataElement(KeyMetaDataAppLovinSdkKey, sdkKey); - elementApplication.Add(metaData); - } - } +// // check if applovin.sdk.key meta data exists. +// if (sdkKeyMetaData != null) +// { +// sdkKeyMetaData.LastAttribute.Value = sdkKey; +// } +// else +// { +// // add applovin.sdk.key meta data if it does not exist. +// var metaData = CreateMetaDataElement(KeyMetaDataAppLovinSdkKey, sdkKey); +// elementApplication.Add(metaData); +// } +// } - private static void EnableVerboseLoggingIfNeeded(XElement elementApplication) - { - var enabled = EditorPrefs.GetBool(MaxSdkLogger.KeyVerboseLoggingEnabled, false); +// private static void EnableVerboseLoggingIfNeeded(XElement elementApplication) +// { +// var enabled = EditorPrefs.GetBool(MaxSdkLogger.KeyVerboseLoggingEnabled, false); - var descendants = elementApplication.Descendants(); - var verboseLoggingMetaData = descendants.FirstOrDefault(descendant => descendant.FirstAttribute != null && - descendant.FirstAttribute.Name.LocalName.Equals("name") && - descendant.FirstAttribute.Value.Equals(KeyMetaDataAppLovinVerboseLoggingOn) && - descendant.LastAttribute != null && - descendant.LastAttribute.Name.LocalName.Equals("value")); +// var descendants = elementApplication.Descendants(); +// var verboseLoggingMetaData = descendants.FirstOrDefault(descendant => descendant.FirstAttribute != null && +// descendant.FirstAttribute.Name.LocalName.Equals("name") && +// descendant.FirstAttribute.Value.Equals(KeyMetaDataAppLovinVerboseLoggingOn) && +// descendant.LastAttribute != null && +// descendant.LastAttribute.Name.LocalName.Equals("value")); - // check if applovin.sdk.verbose_logging meta data exists. - if (verboseLoggingMetaData != null) - { - if (enabled) - { - // update applovin.sdk.verbose_logging meta data value. - verboseLoggingMetaData.LastAttribute.Value = enabled.ToString(); - } - else - { - // remove applovin.sdk.verbose_logging meta data. - verboseLoggingMetaData.Remove(); - } - } - else - { - if (enabled) - { - // add applovin.sdk.verbose_logging meta data if it does not exist. - var metaData = CreateMetaDataElement(KeyMetaDataAppLovinVerboseLoggingOn, enabled.ToString()); - elementApplication.Add(metaData); - } - } - } +// // check if applovin.sdk.verbose_logging meta data exists. +// if (verboseLoggingMetaData != null) +// { +// if (enabled) +// { +// // update applovin.sdk.verbose_logging meta data value. +// verboseLoggingMetaData.LastAttribute.Value = enabled.ToString(); +// } +// else +// { +// // remove applovin.sdk.verbose_logging meta data. +// verboseLoggingMetaData.Remove(); +// } +// } +// else +// { +// if (enabled) +// { +// // add applovin.sdk.verbose_logging meta data if it does not exist. +// var metaData = CreateMetaDataElement(KeyMetaDataAppLovinVerboseLoggingOn, enabled.ToString()); +// elementApplication.Add(metaData); +// } +// } +// } - private static void AddGoogleApplicationIdIfNeeded(XElement elementApplication, IEnumerable metaDataElements) - { - if (!AppLovinIntegrationManager.IsAdapterInstalled("Google") && !AppLovinIntegrationManager.IsAdapterInstalled("GoogleAdManager")) return; +// private static void AddGoogleApplicationIdIfNeeded(XElement elementApplication, IEnumerable metaDataElements) +// { +// if (!AppLovinIntegrationManager.IsAdapterInstalled("Google") && !AppLovinIntegrationManager.IsAdapterInstalled("GoogleAdManager")) return; - var googleApplicationIdMetaData = GetMetaDataElement(metaDataElements, KeyMetaDataGoogleApplicationId); - var appId = AppLovinSettings.Instance.AdMobAndroidAppId; - // Log error if the App ID is not set. - if (string.IsNullOrEmpty(appId) || !appId.StartsWith("ca-app-pub-")) - { - MaxSdkLogger.UserError("Google App ID is not set. Please enter a valid app ID within the AppLovin Integration Manager window."); - return; - } +// var googleApplicationIdMetaData = GetMetaDataElement(metaDataElements, KeyMetaDataGoogleApplicationId); +// var appId = AppLovinSettings.Instance.AdMobAndroidAppId; +// // Log error if the App ID is not set. +// if (string.IsNullOrEmpty(appId) || !appId.StartsWith("ca-app-pub-")) +// { +// MaxSdkLogger.UserError("Google App ID is not set. Please enter a valid app ID within the AppLovin Integration Manager window."); +// return; +// } - // Check if the Google App ID meta data already exists. Update if it already exists. - if (googleApplicationIdMetaData != null) - { - googleApplicationIdMetaData.SetAttributeValue(AndroidNamespace + "value", appId); - } - // Meta data doesn't exist, add it. - else - { - elementApplication.Add(CreateMetaDataElement(KeyMetaDataGoogleApplicationId, appId)); - } - } +// // Check if the Google App ID meta data already exists. Update if it already exists. +// if (googleApplicationIdMetaData != null) +// { +// googleApplicationIdMetaData.SetAttributeValue(AndroidNamespace + "value", appId); +// } +// // Meta data doesn't exist, add it. +// else +// { +// elementApplication.Add(CreateMetaDataElement(KeyMetaDataGoogleApplicationId, appId)); +// } +// } - /// - /// Creates and returns a meta-data element with the given name and value. - /// - private static XElement CreateMetaDataElement(string name, object value) - { - var metaData = new XElement("meta-data"); - metaData.Add(new XAttribute(AndroidNamespace + "name", name)); - metaData.Add(new XAttribute(AndroidNamespace + "value", value)); +// /// +// /// Creates and returns a meta-data element with the given name and value. +// /// +// private static XElement CreateMetaDataElement(string name, object value) +// { +// var metaData = new XElement("meta-data"); +// metaData.Add(new XAttribute(AndroidNamespace + "name", name)); +// metaData.Add(new XAttribute(AndroidNamespace + "value", value)); - return metaData; - } +// return metaData; +// } - /// - /// Looks through all the given meta-data elements to check if the required one exists. Returns null if it doesn't exist. - /// - private static XElement GetMetaDataElement(IEnumerable metaDataElements, string metaDataName) - { - foreach (var metaDataElement in metaDataElements) - { - var attributes = metaDataElement.Attributes(); - if (attributes.Any(attribute => attribute.Name.Namespace.Equals(AndroidNamespace) - && attribute.Name.LocalName.Equals("name") - && attribute.Value.Equals(metaDataName))) - { - return metaDataElement; - } - } +// /// +// /// Looks through all the given meta-data elements to check if the required one exists. Returns null if it doesn't exist. +// /// +// private static XElement GetMetaDataElement(IEnumerable metaDataElements, string metaDataName) +// { +// foreach (var metaDataElement in metaDataElements) +// { +// var attributes = metaDataElement.Attributes(); +// if (attributes.Any(attribute => attribute.Name.Namespace.Equals(AndroidNamespace) +// && attribute.Name.LocalName.Equals("name") +// && attribute.Value.Equals(metaDataName))) +// { +// return metaDataElement; +// } +// } - return null; - } - } +// return null; +// } +// } } #endif diff --git a/Assets/ThirdParty/MaxSdk/Scripts/IntegrationManager/Editor/AppLovinPostProcessAndroidGradle.cs b/Assets/ThirdParty/MaxSdk/Scripts/IntegrationManager/Editor/AppLovinPostProcessAndroidGradle.cs index ad4b31cf0..2711639b4 100644 --- a/Assets/ThirdParty/MaxSdk/Scripts/IntegrationManager/Editor/AppLovinPostProcessAndroidGradle.cs +++ b/Assets/ThirdParty/MaxSdk/Scripts/IntegrationManager/Editor/AppLovinPostProcessAndroidGradle.cs @@ -17,49 +17,49 @@ namespace AppLovinMax.Scripts.IntegrationManager.Editor /// /// Adds Quality Service plugin to the Gradle project once the project has been exported. See for more details. /// - public class AppLovinPostProcessGradleProject : AppLovinProcessGradleBuildFile, IPostGenerateGradleAndroidProject - { - public void OnPostGenerateGradleAndroidProject(string path) - { - if (!AppLovinSettings.Instance.QualityServiceEnabled) return; +// public class AppLovinPostProcessGradleProject : AppLovinProcessGradleBuildFile, IPostGenerateGradleAndroidProject +// { +// public void OnPostGenerateGradleAndroidProject(string path) +// { +// if (!AppLovinSettings.Instance.QualityServiceEnabled) return; -#if UNITY_2019_3_OR_NEWER - // On Unity 2019.3+, the path returned is the path to the unityLibrary's module. - // The AppLovin Quality Service buildscript closure related lines need to be added to the root build.gradle file. - var rootGradleBuildFilePath = Path.Combine(path, "../build.gradle"); -#if UNITY_2022_2_OR_NEWER - if (!AddPluginToRootGradleBuildFile(rootGradleBuildFilePath)) return; +// #if UNITY_2019_3_OR_NEWER +// // On Unity 2019.3+, the path returned is the path to the unityLibrary's module. +// // The AppLovin Quality Service buildscript closure related lines need to be added to the root build.gradle file. +// var rootGradleBuildFilePath = Path.Combine(path, "../build.gradle"); +// #if UNITY_2022_2_OR_NEWER +// if (!AddPluginToRootGradleBuildFile(rootGradleBuildFilePath)) return; - var rootSettingsGradleFilePath = Path.Combine(path, "../settings.gradle"); - if (!AddAppLovinRepository(rootSettingsGradleFilePath)) return; -#else - var buildScriptChangesAdded = AddQualityServiceBuildScriptLines(rootGradleBuildFilePath); - if (!buildScriptChangesAdded) return; -#endif +// var rootSettingsGradleFilePath = Path.Combine(path, "../settings.gradle"); +// if (!AddAppLovinRepository(rootSettingsGradleFilePath)) return; +// #else +// var buildScriptChangesAdded = AddQualityServiceBuildScriptLines(rootGradleBuildFilePath); +// if (!buildScriptChangesAdded) return; +// #endif - // The plugin needs to be added to the application module (named launcher) - var applicationGradleBuildFilePath = Path.Combine(path, "../launcher/build.gradle"); -#else - // If Gradle template is enabled, we would have already updated the plugin. - if (AppLovinIntegrationManager.GradleTemplateEnabled) return; +// // The plugin needs to be added to the application module (named launcher) +// var applicationGradleBuildFilePath = Path.Combine(path, "../launcher/build.gradle"); +// #else +// // If Gradle template is enabled, we would have already updated the plugin. +// if (AppLovinIntegrationManager.GradleTemplateEnabled) return; - var applicationGradleBuildFilePath = Path.Combine(path, "build.gradle"); -#endif +// var applicationGradleBuildFilePath = Path.Combine(path, "build.gradle"); +// #endif - if (!File.Exists(applicationGradleBuildFilePath)) - { - MaxSdkLogger.UserWarning("Couldn't find build.gradle file. Failed to add AppLovin Quality Service plugin to the gradle project."); - return; - } +// if (!File.Exists(applicationGradleBuildFilePath)) +// { +// MaxSdkLogger.UserWarning("Couldn't find build.gradle file. Failed to add AppLovin Quality Service plugin to the gradle project."); +// return; +// } - AddAppLovinQualityServicePlugin(applicationGradleBuildFilePath); - } +// AddAppLovinQualityServicePlugin(applicationGradleBuildFilePath); +// } - public int callbackOrder - { - get { return int.MaxValue; } - } - } +// public int callbackOrder +// { +// get { return int.MaxValue; } +// } +// } } #endif diff --git a/Assets/ThirdParty/MaxSdk/Scripts/IntegrationManager/Editor/AppLovinPreProcessAndroid.cs b/Assets/ThirdParty/MaxSdk/Scripts/IntegrationManager/Editor/AppLovinPreProcessAndroid.cs index 24dd8ad5c..9011499aa 100644 --- a/Assets/ThirdParty/MaxSdk/Scripts/IntegrationManager/Editor/AppLovinPreProcessAndroid.cs +++ b/Assets/ThirdParty/MaxSdk/Scripts/IntegrationManager/Editor/AppLovinPreProcessAndroid.cs @@ -26,166 +26,166 @@ namespace AppLovinMax.Scripts.IntegrationManager.Editor /// /// Adds the AppLovin Quality Service plugin to the gradle template file. See for more details. /// - public class AppLovinPreProcessAndroid : AppLovinProcessGradleBuildFile, -#if UNITY_2018_1_OR_NEWER - IPreprocessBuildWithReport -#else - IPreprocessBuild -#endif - { - private const string AppLovinSettingsFileName = "applovin_settings.json"; +// public class AppLovinPreProcessAndroid : AppLovinProcessGradleBuildFile, +// #if UNITY_2018_1_OR_NEWER +// IPreprocessBuildWithReport +// #else +// IPreprocessBuild +// #endif +// { +// private const string AppLovinSettingsFileName = "applovin_settings.json"; - private const string KeyTermsFlowSettings = "terms_flow_settings"; - private const string KeyTermsFlowEnabled = "terms_flow_enabled"; - private const string KeyTermsFlowTermsOfService = "terms_flow_terms_of_service"; - private const string KeyTermsFlowPrivacyPolicy = "terms_flow_privacy_policy"; +// private const string KeyTermsFlowSettings = "terms_flow_settings"; +// private const string KeyTermsFlowEnabled = "terms_flow_enabled"; +// private const string KeyTermsFlowTermsOfService = "terms_flow_terms_of_service"; +// private const string KeyTermsFlowPrivacyPolicy = "terms_flow_privacy_policy"; - private const string KeyConsentFlowSettings = "consent_flow_settings"; - private const string KeyConsentFlowEnabled = "consent_flow_enabled"; - private const string KeyConsentFlowTermsOfService = "consent_flow_terms_of_service"; - private const string KeyConsentFlowPrivacyPolicy = "consent_flow_privacy_policy"; - private const string KeyConsentFlowAdvertisingPartners = "consent_flow_advertising_partners"; - private const string KeyConsentFlowIncludeDefaultAdvertisingPartners = "consent_flow_should_include_default_advertising_partners"; - private const string KeyConsentFlowAnalyticsPartners = "consent_flow_analytics_partners"; - private const string KeyConsentFlowIncludeDefaultAnalyticsPartners = "consent_flow_should_include_default_analytics_partners"; +// private const string KeyConsentFlowSettings = "consent_flow_settings"; +// private const string KeyConsentFlowEnabled = "consent_flow_enabled"; +// private const string KeyConsentFlowTermsOfService = "consent_flow_terms_of_service"; +// private const string KeyConsentFlowPrivacyPolicy = "consent_flow_privacy_policy"; +// private const string KeyConsentFlowAdvertisingPartners = "consent_flow_advertising_partners"; +// private const string KeyConsentFlowIncludeDefaultAdvertisingPartners = "consent_flow_should_include_default_advertising_partners"; +// private const string KeyConsentFlowAnalyticsPartners = "consent_flow_analytics_partners"; +// private const string KeyConsentFlowIncludeDefaultAnalyticsPartners = "consent_flow_should_include_default_analytics_partners"; -#if UNITY_2018_1_OR_NEWER - public void OnPreprocessBuild(BuildReport report) -#else - public void OnPreprocessBuild(BuildTarget target, string path) -#endif - { - // We can only process gradle template file here. If it is not available, we will try again in post build on Unity IDEs newer than 2018_2 (see AppLovinPostProcessGradleProject). - if (!AppLovinIntegrationManager.GradleTemplateEnabled) return; +// #if UNITY_2018_1_OR_NEWER +// public void OnPreprocessBuild(BuildReport report) +// #else +// public void OnPreprocessBuild(BuildTarget target, string path) +// #endif +// { +// // We can only process gradle template file here. If it is not available, we will try again in post build on Unity IDEs newer than 2018_2 (see AppLovinPostProcessGradleProject). +// if (!AppLovinIntegrationManager.GradleTemplateEnabled) return; -#if UNITY_2019_3_OR_NEWER - // The publisher could be migrating from older Unity versions to 2019_3 or newer. - // If so, we should delete the plugin from the template. The plugin will be added to the project's application module in the post processing script (AppLovinPostProcessGradleProject). - RemoveAppLovinQualityServiceOrSafeDkPlugin(AppLovinIntegrationManager.GradleTemplatePath); -#else - AddAppLovinQualityServicePlugin(AppLovinIntegrationManager.GradleTemplatePath); -#endif +// #if UNITY_2019_3_OR_NEWER +// // The publisher could be migrating from older Unity versions to 2019_3 or newer. +// // If so, we should delete the plugin from the template. The plugin will be added to the project's application module in the post processing script (AppLovinPostProcessGradleProject). +// RemoveAppLovinQualityServiceOrSafeDkPlugin(AppLovinIntegrationManager.GradleTemplatePath); +// #else +// AddAppLovinQualityServicePlugin(AppLovinIntegrationManager.GradleTemplatePath); +// #endif - // For Unity 2018.2 or newer, the consent flow is enabled in MaxPostProcessBuildAndroid. -#if !UNITY_2018_2_OR_NEWER - if (AppLovinSettings.Instance.ShowInternalSettingsInIntegrationManager) - { - var consentFlowSettingsFilePath = Path.Combine("Assets", "Plugin/Android/res/raw/"); - EnableConsentFlowIfNeeded(consentFlowSettingsFilePath); - } -#endif - } +// // For Unity 2018.2 or newer, the consent flow is enabled in MaxPostProcessBuildAndroid. +// #if !UNITY_2018_2_OR_NEWER +// if (AppLovinSettings.Instance.ShowInternalSettingsInIntegrationManager) +// { +// var consentFlowSettingsFilePath = Path.Combine("Assets", "Plugin/Android/res/raw/"); +// EnableConsentFlowIfNeeded(consentFlowSettingsFilePath); +// } +// #endif +// } - public static void EnableConsentFlowIfNeeded(string rawResourceDirectory) - { - // Check if consent flow is enabled. No need to create the applovin_consent_flow_settings.json if consent flow is disabled. - var consentFlowEnabled = AppLovinInternalSettings.Instance.ConsentFlowEnabled; - if (!consentFlowEnabled) return; +// public static void EnableConsentFlowIfNeeded(string rawResourceDirectory) +// { +// // Check if consent flow is enabled. No need to create the applovin_consent_flow_settings.json if consent flow is disabled. +// var consentFlowEnabled = AppLovinInternalSettings.Instance.ConsentFlowEnabled; +// if (!consentFlowEnabled) return; - var privacyPolicyUrl = AppLovinInternalSettings.Instance.ConsentFlowPrivacyPolicyUrl; - if (string.IsNullOrEmpty(privacyPolicyUrl)) - { - AppLovinIntegrationManager.ShowBuildFailureDialog("You cannot use the AppLovin SDK's consent flow without defining a Privacy Policy URL in the AppLovin Integration Manager."); +// var privacyPolicyUrl = AppLovinInternalSettings.Instance.ConsentFlowPrivacyPolicyUrl; +// if (string.IsNullOrEmpty(privacyPolicyUrl)) +// { +// AppLovinIntegrationManager.ShowBuildFailureDialog("You cannot use the AppLovin SDK's consent flow without defining a Privacy Policy URL in the AppLovin Integration Manager."); - // No need to update the applovin_consent_flow_settings.json here. Default consent flow state will be determined on the SDK side. - return; - } +// // No need to update the applovin_consent_flow_settings.json here. Default consent flow state will be determined on the SDK side. +// return; +// } - var consentFlowSettings = new Dictionary(); - consentFlowSettings[KeyConsentFlowEnabled] = consentFlowEnabled; - consentFlowSettings[KeyConsentFlowPrivacyPolicy] = privacyPolicyUrl; +// var consentFlowSettings = new Dictionary(); +// consentFlowSettings[KeyConsentFlowEnabled] = consentFlowEnabled; +// consentFlowSettings[KeyConsentFlowPrivacyPolicy] = privacyPolicyUrl; - var termsOfServiceUrl = AppLovinInternalSettings.Instance.ConsentFlowTermsOfServiceUrl; - if (MaxSdkUtils.IsValidString(termsOfServiceUrl)) - { - consentFlowSettings[KeyConsentFlowTermsOfService] = termsOfServiceUrl; - } +// var termsOfServiceUrl = AppLovinInternalSettings.Instance.ConsentFlowTermsOfServiceUrl; +// if (MaxSdkUtils.IsValidString(termsOfServiceUrl)) +// { +// consentFlowSettings[KeyConsentFlowTermsOfService] = termsOfServiceUrl; +// } - consentFlowSettings[KeyConsentFlowIncludeDefaultAdvertisingPartners] = AppLovinInternalSettings.Instance.ConsentFlowIncludeDefaultAdvertisingPartnerUrls; - var advertisingPartnerUrls = AppLovinInternalSettings.Instance.ConsentFlowAdvertisingPartnerUrls; - if (MaxSdkUtils.IsValidString(advertisingPartnerUrls)) - { - var advertisingPartnerUrlsList = advertisingPartnerUrls.Split(',').ToList(); - consentFlowSettings[KeyConsentFlowAdvertisingPartners] = advertisingPartnerUrlsList; - } +// consentFlowSettings[KeyConsentFlowIncludeDefaultAdvertisingPartners] = AppLovinInternalSettings.Instance.ConsentFlowIncludeDefaultAdvertisingPartnerUrls; +// var advertisingPartnerUrls = AppLovinInternalSettings.Instance.ConsentFlowAdvertisingPartnerUrls; +// if (MaxSdkUtils.IsValidString(advertisingPartnerUrls)) +// { +// var advertisingPartnerUrlsList = advertisingPartnerUrls.Split(',').ToList(); +// consentFlowSettings[KeyConsentFlowAdvertisingPartners] = advertisingPartnerUrlsList; +// } - consentFlowSettings[KeyConsentFlowIncludeDefaultAnalyticsPartners] = AppLovinInternalSettings.Instance.ConsentFlowIncludeDefaultAnalyticsPartnerUrls; - var analyticsPartnerUrls = AppLovinInternalSettings.Instance.ConsentFlowAnalyticsPartnerUrls; - if (MaxSdkUtils.IsValidString(analyticsPartnerUrls)) - { - var analyticsPartnerUrlsList = analyticsPartnerUrls.Split(',').ToList(); - consentFlowSettings[KeyConsentFlowAnalyticsPartners] = analyticsPartnerUrlsList; - } +// consentFlowSettings[KeyConsentFlowIncludeDefaultAnalyticsPartners] = AppLovinInternalSettings.Instance.ConsentFlowIncludeDefaultAnalyticsPartnerUrls; +// var analyticsPartnerUrls = AppLovinInternalSettings.Instance.ConsentFlowAnalyticsPartnerUrls; +// if (MaxSdkUtils.IsValidString(analyticsPartnerUrls)) +// { +// var analyticsPartnerUrlsList = analyticsPartnerUrls.Split(',').ToList(); +// consentFlowSettings[KeyConsentFlowAnalyticsPartners] = analyticsPartnerUrlsList; +// } - var applovinSdkSettings = new Dictionary(); - applovinSdkSettings[KeyConsentFlowSettings] = consentFlowSettings; +// var applovinSdkSettings = new Dictionary(); +// applovinSdkSettings[KeyConsentFlowSettings] = consentFlowSettings; - var applovinSdkSettingsJson = Json.Serialize(applovinSdkSettings); - WriteAppLovinSettingsRawResourceFile(applovinSdkSettingsJson, rawResourceDirectory); - } +// var applovinSdkSettingsJson = Json.Serialize(applovinSdkSettings); +// WriteAppLovinSettingsRawResourceFile(applovinSdkSettingsJson, rawResourceDirectory); +// } - public static void EnableTermsFlowIfNeeded(string rawResourceDirectory) - { - if (AppLovinSettings.Instance.ShowInternalSettingsInIntegrationManager) return; +// public static void EnableTermsFlowIfNeeded(string rawResourceDirectory) +// { +// if (AppLovinSettings.Instance.ShowInternalSettingsInIntegrationManager) return; - // Check if terms flow is enabled. No need to create the applovin_consent_flow_settings.json if consent flow is disabled. - var consentFlowEnabled = AppLovinSettings.Instance.ConsentFlowEnabled; - if (!consentFlowEnabled) return; +// // Check if terms flow is enabled. No need to create the applovin_consent_flow_settings.json if consent flow is disabled. +// var consentFlowEnabled = AppLovinSettings.Instance.ConsentFlowEnabled; +// if (!consentFlowEnabled) return; - // Check if terms flow is enabled for this format. - var consentFlowPlatform = AppLovinSettings.Instance.ConsentFlowPlatform; - if (consentFlowPlatform != Platform.All && consentFlowPlatform != Platform.Android) return; +// // Check if terms flow is enabled for this format. +// var consentFlowPlatform = AppLovinSettings.Instance.ConsentFlowPlatform; +// if (consentFlowPlatform != Platform.All && consentFlowPlatform != Platform.Android) return; - var privacyPolicyUrl = AppLovinSettings.Instance.ConsentFlowPrivacyPolicyUrl; - if (string.IsNullOrEmpty(privacyPolicyUrl)) - { - AppLovinIntegrationManager.ShowBuildFailureDialog("You cannot use the AppLovin SDK's consent flow without defining a Privacy Policy URL in the AppLovin Integration Manager."); +// var privacyPolicyUrl = AppLovinSettings.Instance.ConsentFlowPrivacyPolicyUrl; +// if (string.IsNullOrEmpty(privacyPolicyUrl)) +// { +// AppLovinIntegrationManager.ShowBuildFailureDialog("You cannot use the AppLovin SDK's consent flow without defining a Privacy Policy URL in the AppLovin Integration Manager."); - // No need to update the applovin_consent_flow_settings.json here. Default consent flow state will be determined on the SDK side. - return; - } +// // No need to update the applovin_consent_flow_settings.json here. Default consent flow state will be determined on the SDK side. +// return; +// } - var consentFlowSettings = new Dictionary(); - consentFlowSettings[KeyTermsFlowEnabled] = consentFlowEnabled; - consentFlowSettings[KeyTermsFlowPrivacyPolicy] = privacyPolicyUrl; +// var consentFlowSettings = new Dictionary(); +// consentFlowSettings[KeyTermsFlowEnabled] = consentFlowEnabled; +// consentFlowSettings[KeyTermsFlowPrivacyPolicy] = privacyPolicyUrl; - var termsOfServiceUrl = AppLovinSettings.Instance.ConsentFlowTermsOfServiceUrl; - if (MaxSdkUtils.IsValidString(termsOfServiceUrl)) - { - consentFlowSettings[KeyTermsFlowTermsOfService] = termsOfServiceUrl; - } +// var termsOfServiceUrl = AppLovinSettings.Instance.ConsentFlowTermsOfServiceUrl; +// if (MaxSdkUtils.IsValidString(termsOfServiceUrl)) +// { +// consentFlowSettings[KeyTermsFlowTermsOfService] = termsOfServiceUrl; +// } - var applovinSdkSettings = new Dictionary(); - applovinSdkSettings[KeyTermsFlowSettings] = consentFlowSettings; +// var applovinSdkSettings = new Dictionary(); +// applovinSdkSettings[KeyTermsFlowSettings] = consentFlowSettings; - var applovinSdkSettingsJson = Json.Serialize(applovinSdkSettings); - WriteAppLovinSettingsRawResourceFile(applovinSdkSettingsJson, rawResourceDirectory); - } +// var applovinSdkSettingsJson = Json.Serialize(applovinSdkSettings); +// WriteAppLovinSettingsRawResourceFile(applovinSdkSettingsJson, rawResourceDirectory); +// } - private static void WriteAppLovinSettingsRawResourceFile(string applovinSdkSettingsJson, string rawResourceDirectory) - { - if (!Directory.Exists(rawResourceDirectory)) - { - Directory.CreateDirectory(rawResourceDirectory); - } +// private static void WriteAppLovinSettingsRawResourceFile(string applovinSdkSettingsJson, string rawResourceDirectory) +// { +// if (!Directory.Exists(rawResourceDirectory)) +// { +// Directory.CreateDirectory(rawResourceDirectory); +// } - var consentFlowSettingsFilePath = Path.Combine(rawResourceDirectory, AppLovinSettingsFileName); - try - { - File.WriteAllText(consentFlowSettingsFilePath, applovinSdkSettingsJson + "\n"); - } - catch (Exception exception) - { - MaxSdkLogger.UserError("applovin_settings.json file write failed due to: " + exception.Message); - Console.WriteLine(exception); - } - } +// var consentFlowSettingsFilePath = Path.Combine(rawResourceDirectory, AppLovinSettingsFileName); +// try +// { +// File.WriteAllText(consentFlowSettingsFilePath, applovinSdkSettingsJson + "\n"); +// } +// catch (Exception exception) +// { +// MaxSdkLogger.UserError("applovin_settings.json file write failed due to: " + exception.Message); +// Console.WriteLine(exception); +// } +// } - public int callbackOrder - { - get { return int.MaxValue; } - } - } +// public int callbackOrder +// { +// get { return int.MaxValue; } +// } +// } } #endif diff --git a/Assets/ThirdParty/MaxSdk/Scripts/IntegrationManager/Editor/AppLovinProcessGradleBuildFile.cs b/Assets/ThirdParty/MaxSdk/Scripts/IntegrationManager/Editor/AppLovinProcessGradleBuildFile.cs index 5b767e782..f47f54f5b 100644 --- a/Assets/ThirdParty/MaxSdk/Scripts/IntegrationManager/Editor/AppLovinProcessGradleBuildFile.cs +++ b/Assets/ThirdParty/MaxSdk/Scripts/IntegrationManager/Editor/AppLovinProcessGradleBuildFile.cs @@ -19,561 +19,561 @@ using Debug = UnityEngine.Debug; namespace AppLovinMax.Scripts.IntegrationManager.Editor { - [Serializable] - public class AppLovinQualityServiceData - { - public string api_key; - } +// [Serializable] +// public class AppLovinQualityServiceData +// { +// public string api_key; +// } - /// - /// Adds or updates the AppLovin Quality Service plugin to the provided build.gradle file. - /// If the gradle file already has the plugin, the API key is updated. - /// - public abstract class AppLovinProcessGradleBuildFile - { - private static readonly Regex TokenBuildScriptRepositories = new Regex(".*repositories.*"); - private static readonly Regex TokenBuildScriptDependencies = new Regex(".*classpath \'com.android.tools.build:gradle.*"); - private static readonly Regex TokenApplicationPlugin = new Regex(".*apply plugin: \'com.android.application\'.*"); - private static readonly Regex TokenApiKey = new Regex(".*apiKey.*"); - private static readonly Regex TokenAppLovinPlugin = new Regex(".*apply plugin:.+?(?=applovin-quality-service).*"); +// /// +// /// Adds or updates the AppLovin Quality Service plugin to the provided build.gradle file. +// /// If the gradle file already has the plugin, the API key is updated. +// /// +// public abstract class AppLovinProcessGradleBuildFile +// { +// private static readonly Regex TokenBuildScriptRepositories = new Regex(".*repositories.*"); +// private static readonly Regex TokenBuildScriptDependencies = new Regex(".*classpath \'com.android.tools.build:gradle.*"); +// private static readonly Regex TokenApplicationPlugin = new Regex(".*apply plugin: \'com.android.application\'.*"); +// private static readonly Regex TokenApiKey = new Regex(".*apiKey.*"); +// private static readonly Regex TokenAppLovinPlugin = new Regex(".*apply plugin:.+?(?=applovin-quality-service).*"); -#if UNITY_2022_2_OR_NEWER - private const string PluginsMatcher = "plugins"; - private const string PluginManagementMatcher = "pluginManagement"; - private const string QualityServicePluginRoot = " id 'com.applovin.quality' version '+' apply false // NOTE: Requires version 4.8.3+ for Gradle version 7.2+"; -#endif +// #if UNITY_2022_2_OR_NEWER +// private const string PluginsMatcher = "plugins"; +// private const string PluginManagementMatcher = "pluginManagement"; +// private const string QualityServicePluginRoot = " id 'com.applovin.quality' version '+' apply false // NOTE: Requires version 4.8.3+ for Gradle version 7.2+"; +// #endif - private const string BuildScriptMatcher = "buildscript"; - private const string QualityServiceMavenRepo = "maven { url 'https://artifacts.applovin.com/android'; content { includeGroupByRegex 'com.applovin.*' } }"; - private const string QualityServiceDependencyClassPath = "classpath 'com.applovin.quality:AppLovinQualityServiceGradlePlugin:+'"; - private const string QualityServiceApplyPlugin = "apply plugin: 'applovin-quality-service'"; - private const string QualityServicePlugin = "applovin {"; - private const string QualityServiceApiKey = " apiKey '{0}'"; - private const string QualityServiceBintrayMavenRepo = "https://applovin.bintray.com/Quality-Service"; - private const string QualityServiceNoRegexMavenRepo = "maven { url 'https://artifacts.applovin.com/android' }"; +// private const string BuildScriptMatcher = "buildscript"; +// private const string QualityServiceMavenRepo = "maven { url 'https://artifacts.applovin.com/android'; content { includeGroupByRegex 'com.applovin.*' } }"; +// private const string QualityServiceDependencyClassPath = "classpath 'com.applovin.quality:AppLovinQualityServiceGradlePlugin:+'"; +// private const string QualityServiceApplyPlugin = "apply plugin: 'applovin-quality-service'"; +// private const string QualityServicePlugin = "applovin {"; +// private const string QualityServiceApiKey = " apiKey '{0}'"; +// private const string QualityServiceBintrayMavenRepo = "https://applovin.bintray.com/Quality-Service"; +// private const string QualityServiceNoRegexMavenRepo = "maven { url 'https://artifacts.applovin.com/android' }"; - // Legacy plugin detection variables - private const string QualityServiceDependencyClassPathV3 = "classpath 'com.applovin.quality:AppLovinQualityServiceGradlePlugin:3.+'"; - private static readonly Regex TokenSafeDkLegacyApplyPlugin = new Regex(".*apply plugin:.+?(?=safedk).*"); - private const string SafeDkLegacyPlugin = "safedk {"; - private const string SafeDkLegacyMavenRepo = "http://download.safedk.com"; - private const string SafeDkLegacyDependencyClassPath = "com.safedk:SafeDKGradlePlugin:"; +// // Legacy plugin detection variables +// private const string QualityServiceDependencyClassPathV3 = "classpath 'com.applovin.quality:AppLovinQualityServiceGradlePlugin:3.+'"; +// private static readonly Regex TokenSafeDkLegacyApplyPlugin = new Regex(".*apply plugin:.+?(?=safedk).*"); +// private const string SafeDkLegacyPlugin = "safedk {"; +// private const string SafeDkLegacyMavenRepo = "http://download.safedk.com"; +// private const string SafeDkLegacyDependencyClassPath = "com.safedk:SafeDKGradlePlugin:"; - /// - /// Updates the provided Gradle script to add Quality Service plugin. - /// - /// The gradle file to update. - protected void AddAppLovinQualityServicePlugin(string applicationGradleBuildFilePath) - { - if (!AppLovinSettings.Instance.QualityServiceEnabled) return; +// /// +// /// Updates the provided Gradle script to add Quality Service plugin. +// /// +// /// The gradle file to update. +// protected void AddAppLovinQualityServicePlugin(string applicationGradleBuildFilePath) +// { +// if (!AppLovinSettings.Instance.QualityServiceEnabled) return; - var sdkKey = AppLovinSettings.Instance.SdkKey; - if (string.IsNullOrEmpty(sdkKey)) - { - MaxSdkLogger.UserError("Failed to install AppLovin Quality Service plugin. SDK Key is empty. Please enter the AppLovin SDK Key in the Integration Manager."); - return; - } +// var sdkKey = AppLovinSettings.Instance.SdkKey; +// if (string.IsNullOrEmpty(sdkKey)) +// { +// MaxSdkLogger.UserError("Failed to install AppLovin Quality Service plugin. SDK Key is empty. Please enter the AppLovin SDK Key in the Integration Manager."); +// return; +// } - // Retrieve the API Key using the SDK Key. - var qualityServiceData = RetrieveQualityServiceData(sdkKey); - var apiKey = qualityServiceData.api_key; - if (string.IsNullOrEmpty(apiKey)) - { - MaxSdkLogger.UserError("Failed to install AppLovin Quality Service plugin. API Key is empty."); - return; - } +// // Retrieve the API Key using the SDK Key. +// var qualityServiceData = RetrieveQualityServiceData(sdkKey); +// var apiKey = qualityServiceData.api_key; +// if (string.IsNullOrEmpty(apiKey)) +// { +// MaxSdkLogger.UserError("Failed to install AppLovin Quality Service plugin. API Key is empty."); +// return; +// } - // Generate the updated Gradle file that needs to be written. - var lines = File.ReadAllLines(applicationGradleBuildFilePath).ToList(); - var sanitizedLines = RemoveLegacySafeDkPlugin(lines); - var outputLines = GenerateUpdatedBuildFileLines( - sanitizedLines, - apiKey, -#if UNITY_2019_3_OR_NEWER - false // On Unity 2019.3+, the buildscript closure related lines will to be added to the root build.gradle file. -#else - true -#endif - ); - // outputLines can be null if we couldn't add the plugin. - if (outputLines == null) return; +// // Generate the updated Gradle file that needs to be written. +// var lines = File.ReadAllLines(applicationGradleBuildFilePath).ToList(); +// var sanitizedLines = RemoveLegacySafeDkPlugin(lines); +// var outputLines = GenerateUpdatedBuildFileLines( +// sanitizedLines, +// apiKey, +// #if UNITY_2019_3_OR_NEWER +// false // On Unity 2019.3+, the buildscript closure related lines will to be added to the root build.gradle file. +// #else +// true +// #endif +// ); +// // outputLines can be null if we couldn't add the plugin. +// if (outputLines == null) return; - try - { - File.WriteAllText(applicationGradleBuildFilePath, string.Join("\n", outputLines.ToArray()) + "\n"); - } - catch (Exception exception) - { - MaxSdkLogger.UserError("Failed to install AppLovin Quality Service plugin. Gradle file write failed."); - Console.WriteLine(exception); - } - } -#if UNITY_2022_2_OR_NEWER - /// - /// Adds AppLovin Quality Service plugin DSL element to the project's root build.gradle file. - /// - /// The path to project's root build.gradle file. - /// true when the plugin was added successfully. - protected bool AddPluginToRootGradleBuildFile(string rootGradleBuildFile) - { - var lines = File.ReadAllLines(rootGradleBuildFile).ToList(); - var outputLines = new List(); - var pluginAdded = false; - var insidePluginsClosure = false; - foreach (var line in lines) - { - if (line.Contains(PluginsMatcher)) - { - insidePluginsClosure = true; - } +// try +// { +// File.WriteAllText(applicationGradleBuildFilePath, string.Join("\n", outputLines.ToArray()) + "\n"); +// } +// catch (Exception exception) +// { +// MaxSdkLogger.UserError("Failed to install AppLovin Quality Service plugin. Gradle file write failed."); +// Console.WriteLine(exception); +// } +// } +// #if UNITY_2022_2_OR_NEWER +// /// +// /// Adds AppLovin Quality Service plugin DSL element to the project's root build.gradle file. +// /// +// /// The path to project's root build.gradle file. +// /// true when the plugin was added successfully. +// protected bool AddPluginToRootGradleBuildFile(string rootGradleBuildFile) +// { +// var lines = File.ReadAllLines(rootGradleBuildFile).ToList(); +// var outputLines = new List(); +// var pluginAdded = false; +// var insidePluginsClosure = false; +// foreach (var line in lines) +// { +// if (line.Contains(PluginsMatcher)) +// { +// insidePluginsClosure = true; +// } - if (!pluginAdded && insidePluginsClosure && line.Contains("}")) - { - outputLines.Add(QualityServicePluginRoot); - pluginAdded = true; - insidePluginsClosure = false; - } +// if (!pluginAdded && insidePluginsClosure && line.Contains("}")) +// { +// outputLines.Add(QualityServicePluginRoot); +// pluginAdded = true; +// insidePluginsClosure = false; +// } - outputLines.Add(line); - } +// outputLines.Add(line); +// } - if (!pluginAdded) - { - MaxSdkLogger.UserError("Failed to add AppLovin Quality Service plugin to root gradle file."); - return false; - } +// if (!pluginAdded) +// { +// MaxSdkLogger.UserError("Failed to add AppLovin Quality Service plugin to root gradle file."); +// return false; +// } - try - { - File.WriteAllText(rootGradleBuildFile, string.Join("\n", outputLines.ToArray()) + "\n"); - } - catch (Exception exception) - { - MaxSdkLogger.UserError("Failed to install AppLovin Quality Service plugin. Root Gradle file write failed."); - Console.WriteLine(exception); - return false; - } +// try +// { +// File.WriteAllText(rootGradleBuildFile, string.Join("\n", outputLines.ToArray()) + "\n"); +// } +// catch (Exception exception) +// { +// MaxSdkLogger.UserError("Failed to install AppLovin Quality Service plugin. Root Gradle file write failed."); +// Console.WriteLine(exception); +// return false; +// } - return true; - } +// return true; +// } - /// - /// Adds the AppLovin maven repository to the project's settings.gradle file. - /// - /// The path to the project's settings.gradle file. - /// true if the repository was added successfully. - protected bool AddAppLovinRepository(string settingsGradleFile) - { - var lines = File.ReadLines(settingsGradleFile).ToList(); - var outputLines = new List(); - var mavenRepoAdded = false; - var pluginManagementClosureDepth = 0; - var insidePluginManagementClosure = false; - var pluginManagementMatched = false; - foreach (var line in lines) - { - outputLines.Add(line); +// /// +// /// Adds the AppLovin maven repository to the project's settings.gradle file. +// /// +// /// The path to the project's settings.gradle file. +// /// true if the repository was added successfully. +// protected bool AddAppLovinRepository(string settingsGradleFile) +// { +// var lines = File.ReadLines(settingsGradleFile).ToList(); +// var outputLines = new List(); +// var mavenRepoAdded = false; +// var pluginManagementClosureDepth = 0; +// var insidePluginManagementClosure = false; +// var pluginManagementMatched = false; +// foreach (var line in lines) +// { +// outputLines.Add(line); - if (!pluginManagementMatched && line.Contains(PluginManagementMatcher)) - { - pluginManagementMatched = true; - insidePluginManagementClosure = true; - } +// if (!pluginManagementMatched && line.Contains(PluginManagementMatcher)) +// { +// pluginManagementMatched = true; +// insidePluginManagementClosure = true; +// } - if (insidePluginManagementClosure) - { - if (line.Contains("{")) - { - pluginManagementClosureDepth++; - } +// if (insidePluginManagementClosure) +// { +// if (line.Contains("{")) +// { +// pluginManagementClosureDepth++; +// } - if (line.Contains("}")) - { - pluginManagementClosureDepth--; - } +// if (line.Contains("}")) +// { +// pluginManagementClosureDepth--; +// } - if (pluginManagementClosureDepth == 0) - { - insidePluginManagementClosure = false; - } - } +// if (pluginManagementClosureDepth == 0) +// { +// insidePluginManagementClosure = false; +// } +// } - if (insidePluginManagementClosure) - { - if (!mavenRepoAdded && TokenBuildScriptRepositories.IsMatch(line)) - { - outputLines.Add(GetFormattedBuildScriptLine(QualityServiceMavenRepo)); - mavenRepoAdded = true; - } - } - } +// if (insidePluginManagementClosure) +// { +// if (!mavenRepoAdded && TokenBuildScriptRepositories.IsMatch(line)) +// { +// outputLines.Add(GetFormattedBuildScriptLine(QualityServiceMavenRepo)); +// mavenRepoAdded = true; +// } +// } +// } - if (!mavenRepoAdded) - { - MaxSdkLogger.UserError("Failed to add AppLovin Quality Service plugin maven repo to settings gradle file."); - return false; - } +// if (!mavenRepoAdded) +// { +// MaxSdkLogger.UserError("Failed to add AppLovin Quality Service plugin maven repo to settings gradle file."); +// return false; +// } - try - { - File.WriteAllText(settingsGradleFile, string.Join("\n", outputLines.ToArray()) + "\n"); - } - catch (Exception exception) - { - MaxSdkLogger.UserError("Failed to install AppLovin Quality Service plugin. Setting Gradle file write failed."); - Console.WriteLine(exception); - return false; - } +// try +// { +// File.WriteAllText(settingsGradleFile, string.Join("\n", outputLines.ToArray()) + "\n"); +// } +// catch (Exception exception) +// { +// MaxSdkLogger.UserError("Failed to install AppLovin Quality Service plugin. Setting Gradle file write failed."); +// Console.WriteLine(exception); +// return false; +// } - return true; - } -#endif +// return true; +// } +// #endif -#if UNITY_2019_3_OR_NEWER - /// - /// Adds the necessary AppLovin Quality Service dependency and maven repo lines to the provided root build.gradle file. - /// - /// The root build.gradle file path - /// true if the build script lines were applied correctly. - protected bool AddQualityServiceBuildScriptLines(string rootGradleBuildFile) - { - var lines = File.ReadAllLines(rootGradleBuildFile).ToList(); - var outputLines = GenerateUpdatedBuildFileLines(lines, null, true); +// #if UNITY_2019_3_OR_NEWER +// /// +// /// Adds the necessary AppLovin Quality Service dependency and maven repo lines to the provided root build.gradle file. +// /// +// /// The root build.gradle file path +// /// true if the build script lines were applied correctly. +// protected bool AddQualityServiceBuildScriptLines(string rootGradleBuildFile) +// { +// var lines = File.ReadAllLines(rootGradleBuildFile).ToList(); +// var outputLines = GenerateUpdatedBuildFileLines(lines, null, true); - // outputLines will be null if we couldn't add the build script lines. - if (outputLines == null) return false; +// // outputLines will be null if we couldn't add the build script lines. +// if (outputLines == null) return false; - try - { - File.WriteAllText(rootGradleBuildFile, string.Join("\n", outputLines.ToArray()) + "\n"); - } - catch (Exception exception) - { - MaxSdkLogger.UserError("Failed to install AppLovin Quality Service plugin. Root Gradle file write failed."); - Console.WriteLine(exception); - return false; - } +// try +// { +// File.WriteAllText(rootGradleBuildFile, string.Join("\n", outputLines.ToArray()) + "\n"); +// } +// catch (Exception exception) +// { +// MaxSdkLogger.UserError("Failed to install AppLovin Quality Service plugin. Root Gradle file write failed."); +// Console.WriteLine(exception); +// return false; +// } - return true; - } +// return true; +// } - /// - /// Removes the AppLovin Quality Service Plugin or Legacy SafeDK plugin from the given gradle template file if either of them are present. - /// - /// The gradle template file from which to remove the plugin from - protected static void RemoveAppLovinQualityServiceOrSafeDkPlugin(string gradleTemplateFile) - { - var lines = File.ReadAllLines(gradleTemplateFile).ToList(); - lines = RemoveLegacySafeDkPlugin(lines); - lines = RemoveAppLovinQualityServicePlugin(lines); +// /// +// /// Removes the AppLovin Quality Service Plugin or Legacy SafeDK plugin from the given gradle template file if either of them are present. +// /// +// /// The gradle template file from which to remove the plugin from +// protected static void RemoveAppLovinQualityServiceOrSafeDkPlugin(string gradleTemplateFile) +// { +// var lines = File.ReadAllLines(gradleTemplateFile).ToList(); +// lines = RemoveLegacySafeDkPlugin(lines); +// lines = RemoveAppLovinQualityServicePlugin(lines); - try - { - File.WriteAllText(gradleTemplateFile, string.Join("\n", lines.ToArray()) + "\n"); - } - catch (Exception exception) - { - MaxSdkLogger.UserError("Failed to remove AppLovin Quality Service Plugin from mainTemplate.gradle. Please remove the Quality Service plugin from the mainTemplate.gradle manually."); - Console.WriteLine(exception); - } - } -#endif +// try +// { +// File.WriteAllText(gradleTemplateFile, string.Join("\n", lines.ToArray()) + "\n"); +// } +// catch (Exception exception) +// { +// MaxSdkLogger.UserError("Failed to remove AppLovin Quality Service Plugin from mainTemplate.gradle. Please remove the Quality Service plugin from the mainTemplate.gradle manually."); +// Console.WriteLine(exception); +// } +// } +// #endif - private static AppLovinQualityServiceData RetrieveQualityServiceData(string sdkKey) - { - var postJson = string.Format("{{\"sdk_key\" : \"{0}\"}}", sdkKey); - var bodyRaw = Encoding.UTF8.GetBytes(postJson); - // Upload handler is automatically disposed when UnityWebRequest is disposed - var uploadHandler = new UploadHandlerRaw(bodyRaw); - uploadHandler.contentType = "application/json"; +// private static AppLovinQualityServiceData RetrieveQualityServiceData(string sdkKey) +// { +// var postJson = string.Format("{{\"sdk_key\" : \"{0}\"}}", sdkKey); +// var bodyRaw = Encoding.UTF8.GetBytes(postJson); +// // Upload handler is automatically disposed when UnityWebRequest is disposed +// var uploadHandler = new UploadHandlerRaw(bodyRaw); +// uploadHandler.contentType = "application/json"; - using (var unityWebRequest = new UnityWebRequest("https://api2.safedk.com/v1/build/cred")) - { - unityWebRequest.method = UnityWebRequest.kHttpVerbPOST; - unityWebRequest.uploadHandler = uploadHandler; - unityWebRequest.downloadHandler = new DownloadHandlerBuffer(); +// using (var unityWebRequest = new UnityWebRequest("https://api2.safedk.com/v1/build/cred")) +// { +// unityWebRequest.method = UnityWebRequest.kHttpVerbPOST; +// unityWebRequest.uploadHandler = uploadHandler; +// unityWebRequest.downloadHandler = new DownloadHandlerBuffer(); -#if UNITY_2017_2_OR_NEWER - var operation = unityWebRequest.SendWebRequest(); -#else - var operation = webRequest.Send(); -#endif +// #if UNITY_2017_2_OR_NEWER +// var operation = unityWebRequest.SendWebRequest(); +// #else +// var operation = webRequest.Send(); +// #endif - // Wait for the download to complete or the request to timeout. - while (!operation.isDone) { } +// // Wait for the download to complete or the request to timeout. +// while (!operation.isDone) { } -#if UNITY_2020_1_OR_NEWER - if (unityWebRequest.result != UnityWebRequest.Result.Success) -#elif UNITY_2017_2_OR_NEWER - if (unityWebRequest.isNetworkError || unityWebRequest.isHttpError) -#else - if (webRequest.isError) -#endif - { - MaxSdkLogger.UserError("Failed to retrieve API Key for SDK Key: " + sdkKey + "with error: " + unityWebRequest.error); - return new AppLovinQualityServiceData(); - } +// #if UNITY_2020_1_OR_NEWER +// if (unityWebRequest.result != UnityWebRequest.Result.Success) +// #elif UNITY_2017_2_OR_NEWER +// if (unityWebRequest.isNetworkError || unityWebRequest.isHttpError) +// #else +// if (webRequest.isError) +// #endif +// { +// MaxSdkLogger.UserError("Failed to retrieve API Key for SDK Key: " + sdkKey + "with error: " + unityWebRequest.error); +// return new AppLovinQualityServiceData(); +// } - try - { - return JsonUtility.FromJson(unityWebRequest.downloadHandler.text); - } - catch (Exception exception) - { - MaxSdkLogger.UserError("Failed to parse API Key." + exception); - return new AppLovinQualityServiceData(); - } - } - } +// try +// { +// return JsonUtility.FromJson(unityWebRequest.downloadHandler.text); +// } +// catch (Exception exception) +// { +// MaxSdkLogger.UserError("Failed to parse API Key." + exception); +// return new AppLovinQualityServiceData(); +// } +// } +// } - private static List RemoveLegacySafeDkPlugin(List lines) - { - return RemovePlugin(lines, SafeDkLegacyPlugin, SafeDkLegacyMavenRepo, SafeDkLegacyDependencyClassPath, TokenSafeDkLegacyApplyPlugin); - } +// private static List RemoveLegacySafeDkPlugin(List lines) +// { +// return RemovePlugin(lines, SafeDkLegacyPlugin, SafeDkLegacyMavenRepo, SafeDkLegacyDependencyClassPath, TokenSafeDkLegacyApplyPlugin); +// } - private static List RemoveAppLovinQualityServicePlugin(List lines) - { - return RemovePlugin(lines, QualityServicePlugin, QualityServiceMavenRepo, QualityServiceDependencyClassPath, TokenAppLovinPlugin); - } +// private static List RemoveAppLovinQualityServicePlugin(List lines) +// { +// return RemovePlugin(lines, QualityServicePlugin, QualityServiceMavenRepo, QualityServiceDependencyClassPath, TokenAppLovinPlugin); +// } - private static List RemovePlugin(List lines, string pluginLine, string mavenRepo, string dependencyClassPath, Regex applyPluginToken) - { - var sanitizedLines = new List(); - var legacyRepoRemoved = false; - var legacyDependencyClassPathRemoved = false; - var legacyPluginRemoved = false; - var legacyPluginMatched = false; - var insideLegacySafeDkClosure = false; - foreach (var line in lines) - { - if (!legacyPluginMatched && line.Contains(pluginLine)) - { - legacyPluginMatched = true; - insideLegacySafeDkClosure = true; - } +// private static List RemovePlugin(List lines, string pluginLine, string mavenRepo, string dependencyClassPath, Regex applyPluginToken) +// { +// var sanitizedLines = new List(); +// var legacyRepoRemoved = false; +// var legacyDependencyClassPathRemoved = false; +// var legacyPluginRemoved = false; +// var legacyPluginMatched = false; +// var insideLegacySafeDkClosure = false; +// foreach (var line in lines) +// { +// if (!legacyPluginMatched && line.Contains(pluginLine)) +// { +// legacyPluginMatched = true; +// insideLegacySafeDkClosure = true; +// } - if (insideLegacySafeDkClosure && line.Contains("}")) - { - insideLegacySafeDkClosure = false; - continue; - } +// if (insideLegacySafeDkClosure && line.Contains("}")) +// { +// insideLegacySafeDkClosure = false; +// continue; +// } - if (insideLegacySafeDkClosure) - { - continue; - } +// if (insideLegacySafeDkClosure) +// { +// continue; +// } - if (!legacyRepoRemoved && line.Contains(mavenRepo)) - { - legacyRepoRemoved = true; - continue; - } +// if (!legacyRepoRemoved && line.Contains(mavenRepo)) +// { +// legacyRepoRemoved = true; +// continue; +// } - if (!legacyDependencyClassPathRemoved && line.Contains(dependencyClassPath)) - { - legacyDependencyClassPathRemoved = true; - continue; - } +// if (!legacyDependencyClassPathRemoved && line.Contains(dependencyClassPath)) +// { +// legacyDependencyClassPathRemoved = true; +// continue; +// } - if (!legacyPluginRemoved && applyPluginToken.IsMatch(line)) - { - legacyPluginRemoved = true; - continue; - } +// if (!legacyPluginRemoved && applyPluginToken.IsMatch(line)) +// { +// legacyPluginRemoved = true; +// continue; +// } - sanitizedLines.Add(line); - } +// sanitizedLines.Add(line); +// } - return sanitizedLines; - } +// return sanitizedLines; +// } - private static List GenerateUpdatedBuildFileLines(List lines, string apiKey, bool addBuildScriptLines) - { - var addPlugin = !string.IsNullOrEmpty(apiKey); - // A sample of the template file. - // ... - // allprojects { - // repositories {**ARTIFACTORYREPOSITORY** - // google() - // jcenter() - // flatDir { - // dirs 'libs' - // } - // } - // } - // - // apply plugin: 'com.android.application' - // **APPLY_PLUGINS** - // - // dependencies { - // implementation fileTree(dir: 'libs', include: ['*.jar']) - // **DEPS**} - // ... - var outputLines = new List(); - // Check if the plugin exists, if so, update the SDK Key. - var pluginExists = lines.Any(line => TokenAppLovinPlugin.IsMatch(line)); - if (pluginExists) - { - var pluginMatched = false; - var insideAppLovinClosure = false; - var updatedApiKey = false; - var mavenRepoUpdated = false; - var dependencyClassPathUpdated = false; - foreach (var line in lines) - { - // Bintray maven repo is no longer being used. Update to s3 maven repo with regex check - if (!mavenRepoUpdated && (line.Contains(QualityServiceBintrayMavenRepo) || line.Contains(QualityServiceNoRegexMavenRepo))) - { - outputLines.Add(GetFormattedBuildScriptLine(QualityServiceMavenRepo)); - mavenRepoUpdated = true; - continue; - } +// private static List GenerateUpdatedBuildFileLines(List lines, string apiKey, bool addBuildScriptLines) +// { +// var addPlugin = !string.IsNullOrEmpty(apiKey); +// // A sample of the template file. +// // ... +// // allprojects { +// // repositories {**ARTIFACTORYREPOSITORY** +// // google() +// // jcenter() +// // flatDir { +// // dirs 'libs' +// // } +// // } +// // } +// // +// // apply plugin: 'com.android.application' +// // **APPLY_PLUGINS** +// // +// // dependencies { +// // implementation fileTree(dir: 'libs', include: ['*.jar']) +// // **DEPS**} +// // ... +// var outputLines = new List(); +// // Check if the plugin exists, if so, update the SDK Key. +// var pluginExists = lines.Any(line => TokenAppLovinPlugin.IsMatch(line)); +// if (pluginExists) +// { +// var pluginMatched = false; +// var insideAppLovinClosure = false; +// var updatedApiKey = false; +// var mavenRepoUpdated = false; +// var dependencyClassPathUpdated = false; +// foreach (var line in lines) +// { +// // Bintray maven repo is no longer being used. Update to s3 maven repo with regex check +// if (!mavenRepoUpdated && (line.Contains(QualityServiceBintrayMavenRepo) || line.Contains(QualityServiceNoRegexMavenRepo))) +// { +// outputLines.Add(GetFormattedBuildScriptLine(QualityServiceMavenRepo)); +// mavenRepoUpdated = true; +// continue; +// } - // We no longer use version specific dependency class path. Just use + for version to always pull the latest. - if (!dependencyClassPathUpdated && line.Contains(QualityServiceDependencyClassPathV3)) - { - outputLines.Add(GetFormattedBuildScriptLine(QualityServiceDependencyClassPath)); - dependencyClassPathUpdated = true; - continue; - } +// // We no longer use version specific dependency class path. Just use + for version to always pull the latest. +// if (!dependencyClassPathUpdated && line.Contains(QualityServiceDependencyClassPathV3)) +// { +// outputLines.Add(GetFormattedBuildScriptLine(QualityServiceDependencyClassPath)); +// dependencyClassPathUpdated = true; +// continue; +// } - if (!pluginMatched && line.Contains(QualityServicePlugin)) - { - insideAppLovinClosure = true; - pluginMatched = true; - } +// if (!pluginMatched && line.Contains(QualityServicePlugin)) +// { +// insideAppLovinClosure = true; +// pluginMatched = true; +// } - if (insideAppLovinClosure && line.Contains("}")) - { - insideAppLovinClosure = false; - } +// if (insideAppLovinClosure && line.Contains("}")) +// { +// insideAppLovinClosure = false; +// } - // Update the API key. - if (insideAppLovinClosure && !updatedApiKey && TokenApiKey.IsMatch(line)) - { - outputLines.Add(string.Format(QualityServiceApiKey, apiKey)); - updatedApiKey = true; - } - // Keep adding the line until we find and update the plugin. - else - { - outputLines.Add(line); - } - } - } - // Plugin hasn't been added yet, add it. - else - { - var buildScriptClosureDepth = 0; - var insideBuildScriptClosure = false; - var buildScriptMatched = false; - var qualityServiceRepositoryAdded = false; - var qualityServiceDependencyClassPathAdded = false; - var qualityServicePluginAdded = false; - foreach (var line in lines) - { - // Add the line to the output lines. - outputLines.Add(line); +// // Update the API key. +// if (insideAppLovinClosure && !updatedApiKey && TokenApiKey.IsMatch(line)) +// { +// outputLines.Add(string.Format(QualityServiceApiKey, apiKey)); +// updatedApiKey = true; +// } +// // Keep adding the line until we find and update the plugin. +// else +// { +// outputLines.Add(line); +// } +// } +// } +// // Plugin hasn't been added yet, add it. +// else +// { +// var buildScriptClosureDepth = 0; +// var insideBuildScriptClosure = false; +// var buildScriptMatched = false; +// var qualityServiceRepositoryAdded = false; +// var qualityServiceDependencyClassPathAdded = false; +// var qualityServicePluginAdded = false; +// foreach (var line in lines) +// { +// // Add the line to the output lines. +// outputLines.Add(line); - // Check if we need to add the build script lines and add them. - if (addBuildScriptLines) - { - if (!buildScriptMatched && line.Contains(BuildScriptMatcher)) - { - buildScriptMatched = true; - insideBuildScriptClosure = true; - } +// // Check if we need to add the build script lines and add them. +// if (addBuildScriptLines) +// { +// if (!buildScriptMatched && line.Contains(BuildScriptMatcher)) +// { +// buildScriptMatched = true; +// insideBuildScriptClosure = true; +// } - // Match the parenthesis to track if we are still inside the buildscript closure. - if (insideBuildScriptClosure) - { - if (line.Contains("{")) - { - buildScriptClosureDepth++; - } +// // Match the parenthesis to track if we are still inside the buildscript closure. +// if (insideBuildScriptClosure) +// { +// if (line.Contains("{")) +// { +// buildScriptClosureDepth++; +// } - if (line.Contains("}")) - { - buildScriptClosureDepth--; - } +// if (line.Contains("}")) +// { +// buildScriptClosureDepth--; +// } - if (buildScriptClosureDepth == 0) - { - insideBuildScriptClosure = false; +// if (buildScriptClosureDepth == 0) +// { +// insideBuildScriptClosure = false; - // There may be multiple buildscript closures and we need to keep looking until we added both the repository and classpath. - buildScriptMatched = qualityServiceRepositoryAdded && qualityServiceDependencyClassPathAdded; - } - } +// // There may be multiple buildscript closures and we need to keep looking until we added both the repository and classpath. +// buildScriptMatched = qualityServiceRepositoryAdded && qualityServiceDependencyClassPathAdded; +// } +// } - if (insideBuildScriptClosure) - { - // Add the build script dependency repositories. - if (!qualityServiceRepositoryAdded && TokenBuildScriptRepositories.IsMatch(line)) - { - outputLines.Add(GetFormattedBuildScriptLine(QualityServiceMavenRepo)); - qualityServiceRepositoryAdded = true; - } - // Add the build script dependencies. - else if (!qualityServiceDependencyClassPathAdded && TokenBuildScriptDependencies.IsMatch(line)) - { - outputLines.Add(GetFormattedBuildScriptLine(QualityServiceDependencyClassPath)); - qualityServiceDependencyClassPathAdded = true; - } - } - } +// if (insideBuildScriptClosure) +// { +// // Add the build script dependency repositories. +// if (!qualityServiceRepositoryAdded && TokenBuildScriptRepositories.IsMatch(line)) +// { +// outputLines.Add(GetFormattedBuildScriptLine(QualityServiceMavenRepo)); +// qualityServiceRepositoryAdded = true; +// } +// // Add the build script dependencies. +// else if (!qualityServiceDependencyClassPathAdded && TokenBuildScriptDependencies.IsMatch(line)) +// { +// outputLines.Add(GetFormattedBuildScriptLine(QualityServiceDependencyClassPath)); +// qualityServiceDependencyClassPathAdded = true; +// } +// } +// } - // Check if we need to add the plugin and add it. - if (addPlugin) - { - // Add the plugin. - if (!qualityServicePluginAdded && TokenApplicationPlugin.IsMatch(line)) - { - outputLines.Add(QualityServiceApplyPlugin); - outputLines.AddRange(GenerateAppLovinPluginClosure(apiKey)); - qualityServicePluginAdded = true; - } - } - } +// // Check if we need to add the plugin and add it. +// if (addPlugin) +// { +// // Add the plugin. +// if (!qualityServicePluginAdded && TokenApplicationPlugin.IsMatch(line)) +// { +// outputLines.Add(QualityServiceApplyPlugin); +// outputLines.AddRange(GenerateAppLovinPluginClosure(apiKey)); +// qualityServicePluginAdded = true; +// } +// } +// } - if ((addBuildScriptLines && (!qualityServiceRepositoryAdded || !qualityServiceDependencyClassPathAdded)) || (addPlugin && !qualityServicePluginAdded)) - { - MaxSdkLogger.UserError("Failed to add AppLovin Quality Service plugin. Quality Service Plugin Added?: " + qualityServicePluginAdded + ", Quality Service Repo added?: " + qualityServiceRepositoryAdded + ", Quality Service dependency added?: " + qualityServiceDependencyClassPathAdded); - return null; - } - } +// if ((addBuildScriptLines && (!qualityServiceRepositoryAdded || !qualityServiceDependencyClassPathAdded)) || (addPlugin && !qualityServicePluginAdded)) +// { +// MaxSdkLogger.UserError("Failed to add AppLovin Quality Service plugin. Quality Service Plugin Added?: " + qualityServicePluginAdded + ", Quality Service Repo added?: " + qualityServiceRepositoryAdded + ", Quality Service dependency added?: " + qualityServiceDependencyClassPathAdded); +// return null; +// } +// } - return outputLines; - } +// return outputLines; +// } - private static string GetFormattedBuildScriptLine(string buildScriptLine) - { -#if UNITY_2022_2_OR_NEWER - return " " -#elif UNITY_2019_3_OR_NEWER - return " " -#else - return " " -#endif - + buildScriptLine; - } +// private static string GetFormattedBuildScriptLine(string buildScriptLine) +// { +// #if UNITY_2022_2_OR_NEWER +// return " " +// #elif UNITY_2019_3_OR_NEWER +// return " " +// #else +// return " " +// #endif +// + buildScriptLine; +// } - private static IEnumerable GenerateAppLovinPluginClosure(string apiKey) - { - // applovin { - // // NOTE: DO NOT CHANGE - this is NOT your AppLovin MAX SDK key - this is a derived key. - // apiKey "456...a1b" - // } - var linesToInject = new List(5); - linesToInject.Add(""); - linesToInject.Add("applovin {"); - linesToInject.Add(" // NOTE: DO NOT CHANGE - this is NOT your AppLovin MAX SDK key - this is a derived key."); - linesToInject.Add(string.Format(QualityServiceApiKey, apiKey)); - linesToInject.Add("}"); +// private static IEnumerable GenerateAppLovinPluginClosure(string apiKey) +// { +// // applovin { +// // // NOTE: DO NOT CHANGE - this is NOT your AppLovin MAX SDK key - this is a derived key. +// // apiKey "456...a1b" +// // } +// var linesToInject = new List(5); +// linesToInject.Add(""); +// linesToInject.Add("applovin {"); +// linesToInject.Add(" // NOTE: DO NOT CHANGE - this is NOT your AppLovin MAX SDK key - this is a derived key."); +// linesToInject.Add(string.Format(QualityServiceApiKey, apiKey)); +// linesToInject.Add("}"); - return linesToInject; - } - } +// return linesToInject; +// } +// } } #endif