private void ExcludeMobileAppKitFromMopub(BuildDotGradle buildDotGradle)
        {
            const string mopubPackage       = "com.skillz-mopub:mopub-sdk-base";
            const string mobileAppKitModule = "moat-mobile-app-kit";

            buildDotGradle.ExcludeItemFromDependency(mobileAppKitModule, mopubPackage, ExcludeType.Module);
        }
        private void ExcludeCardIoFromPaypal(BuildDotGradle buildDotGradle)
        {
            const string paypalPackage = "com.paypal.sdk:paypal-android-sdk";
            const string cardIoGroup   = "io.card";

            buildDotGradle.ExcludeItemFromDependency(cardIoGroup, paypalPackage);
        }
        private void ModifyGradleFile(string gradlePath)
        {
            if (!File.Exists(gradlePath))
            {
                return;
            }

            Debug.Log(string.Format(Constants.LogFormat, $"Modifying '{gradlePath}'"));

            using (var buildDotGradle = new BuildDotGradle(gradlePath))
            {
                // HACK: Manually excluding some transitive dependencies because
                // the Google Play Resolver currently does not have exclusion semantics!!!
                //
                // The GPR resolves dependencies either by patching the gradle template
                // or downloading AARs, so sweep the gradle file for both.

                ExcludeCardIoFromPaypal(buildDotGradle);
                ExcludeCardIoAAR(buildDotGradle);

                ExcludeMobileAppKitFromMopub(buildDotGradle);
                ExcludeMobileAppKitAAR(buildDotGradle);

                ExcludeReactFromLinearGradient(buildDotGradle);
                ExcludeReactFromImagePicker(buildDotGradle);
                ExcludeReactFromScrollView(buildDotGradle);
                ExcludeReactAAR(buildDotGradle);

                PatchFirebaseLocalRepoPath(buildDotGradle);

                RemoveMoatRepository(buildDotGradle);
            }
        }
        private void PatchFirebaseLocalRepoPath(BuildDotGradle buildDotGradle)
        {
            // Works around a bug in v1.2.155 (or earlier) of the Play Resolver where the path for the
            // local repo for Firebase packages is incorrect. We bundle v1.2.156, which fixes the bug,
            // but adding this workaround in case a developer unintentionally is using a version
            // of the Play Resolver that has the bug.
            //
            // See: https://github.com/firebase/quickstart-unity/issues/655#issuecomment-647238128

            buildDotGradle.FixFirebaseLocalRepoPath();
        }
        private void RemoveMoatRepository(BuildDotGradle buildDotGradle)
        {
            if (EditorUserBuildSettings.exportAsGoogleAndroidProject)
            {
                return;
            }

            Debug.Log("Removing the moat repository so that an APK can be built directly in Unity 2018-");

            // Works around an issue building an APK directly where Unity's
            // Gradle 5.1.1 can't access the moat repository and returns a 403.
            // The repo can be safely removed as it was only included for AAR route
            // of dependency resolution, and our copy of Mopub doesn't use any moat dependencies.

            buildDotGradle.RemoveMoatRepository();
        }
        private void ModifyFirebaseGradle(string firebaseGradlePath)
        {
            if (!File.Exists(firebaseGradlePath))
            {
                return;
            }

            Debug.Log(string.Format(Constants.LogFormat, "Making adjustments to Firebase's build.gradle"));

            const uint   androidSdkLevel           = 28;
            const string androidToolsPluginVersion = "3.5.2";

            using (var buildDotGradle = new BuildDotGradle(firebaseGradlePath))
            {
                buildDotGradle.ChangeCompileSdkVersion(androidSdkLevel);
                buildDotGradle.ChangeTargetSdkVersion(androidSdkLevel);
                buildDotGradle.ChangeAndroidToolsPluginVersion(androidToolsPluginVersion);
            }
        }
 private void ExcludeReactAAR(BuildDotGradle buildDotGradle)
 {
     // Ensure the stock react-native package doesn't conflict with the V8 counterpart
     buildDotGradle.ExcludeAARDependency("com.facebook.react.react-native-0.59.10");
 }
        private void ExcludeReactFromPackage(BuildDotGradle buildDotGradle, string packageName)
        {
            const string reactGroup = "com.facebook.react";

            buildDotGradle.ExcludeItemFromDependency(reactGroup, packageName);
        }
        private void ExcludeReactFromScrollView(BuildDotGradle buildDotGradle)
        {
            const string scrollViewPackage = "com.react-native-spring-scrollview:react-native-spring-scrollview-android";

            ExcludeReactFromPackage(buildDotGradle, scrollViewPackage);
        }
        private void ExcludeReactFromImagePicker(BuildDotGradle buildDotGradle)
        {
            const string imagePickerPackage = "com.react-native-image-picker:rn-image-picker-android";

            ExcludeReactFromPackage(buildDotGradle, imagePickerPackage);
        }
        private void ExcludeReactFromLinearGradient(BuildDotGradle buildDotGradle)
        {
            const string linearGradientPackage = "com.BV:react-native-linear-gradient";

            ExcludeReactFromPackage(buildDotGradle, linearGradientPackage);
        }
        private void ExcludeMobileAppKitAAR(BuildDotGradle buildDotGradle)
        {
            const string mobileAppKitPackage = "com.moat.analytics.mobile.mpub.moat-mobile-app-kit-2.4.5";

            buildDotGradle.ExcludeAARDependency(mobileAppKitPackage);
        }
        private void ExcludeCardIoAAR(BuildDotGradle buildDotGradle)
        {
            const string cardIoName = "io.card.android-sdk-5.4.0";

            buildDotGradle.ExcludeAARDependency(cardIoName);
        }