private void EnableAndroidxInGradleProperties(string projectGradlePropertiesPath)
        {
            Debug.Log($"Adding two properties to '{projectGradlePropertiesPath}' to enable Androidx");

            // https://stackoverflow.com/questions/52033810/can-i-use-library-that-used-android-support-with-androidx-projects
            const string useAndroidX    = "android.useAndroidX=true";
            const string enableJetifier = "android.enableJetifier=true";

            using (var projectGradleProperties = new GradleProperties(projectGradlePropertiesPath))
            {
                // The developer should have checked the "Use Jetifier" option in the
                // Google Play Services Resolver to swap out the old App Compat libraries
                // for their Androidx counterparts. However, enable it in the exported
                // project as a precaution in case they did not.

                if (!projectGradleProperties.FileContents.Contains(useAndroidX))
                {
                    projectGradleProperties.Append(useAndroidX);
                }

                if (!projectGradleProperties.FileContents.Contains(enableJetifier))
                {
                    projectGradleProperties.Append(enableJetifier);
                }
            }
        }
        private void AddExportedProjectInGradleProperties(string projectGradlePropertiesPath)
        {
            Debug.Log($"Adding EXPORTED_PROJECT in '{projectGradlePropertiesPath}'");

            // Property to select the Gradle plugin version depending on if
            // the Android Studio project is exported or not.
            // Skillz normally relies on Gradle 5.4.1 but Unity uses its own copy:
            // https://docs.unity3d.com/Manual/android-gradle-overview.html

            string exportedProject = $"EXPORTED_PROJECT={EditorUserBuildSettings.exportAsGoogleAndroidProject.ToString().ToLowerInvariant()}";

            using (var projectGradleProperties = new GradleProperties(projectGradlePropertiesPath))
            {
                var fileContents = projectGradleProperties.FileContents.ToList();
                var index        = fileContents.FindIndex(0, fileContents.Count, line => line.Contains("EXPORTED_PROJECT="));
                if (index != -1)
                {
                    projectGradleProperties.SetAt(index, exportedProject);
                }
                else
                {
                    projectGradleProperties.Append(exportedProject);
                }
            }
        }
        private void AppendLocallySetSdkVersionToGradleProperties(string projectGradlePropertiesPath)
        {
            if (!UseLocallyProvidedSkillzVersion(out string localSkillzVersion))
            {
                return;
            }

            Debug.Log(string.Format(Constants.LogFormat, $"Appending {Constants.SkillzVersionVariable}={localSkillzVersion} to '{projectGradlePropertiesPath}'"));
            using (var projectGradleProperties = new GradleProperties(projectGradlePropertiesPath))
            {
                projectGradleProperties.Append($"{Constants.SkillzVersionVariable}={localSkillzVersion}");
            }
        }
        private void EnableR8InGradleProperties(string projectGradlePropertiesPath)
        {
            Debug.Log($"Enabling R8 in '{projectGradlePropertiesPath}'");

            // https://stackoverflow.com/questions/57635963/gradle-dsl-element-useproguard-is-obsolete-and-will-be-removed-soon
            const string enableR8 = "android.enableR8=true";

            using (var projectGradleProperties = new GradleProperties(projectGradlePropertiesPath))
            {
                if (!projectGradleProperties.FileContents.Contains(enableR8))
                {
                    projectGradleProperties.Append(enableR8);
                }
            }
        }