예제 #1
0
 public AddMinAndTargetSDK(string manifest, string minSDK, string targetSDK) : base(
         AppodealUnityUtils.absolute2Relative(manifest) +
         " doesn't contain minSdkVersion or targetSdkVersion (or both). It leads to unwanted permissions in the final build.",
         true)
 {
     this.manifest         = manifest;
     this.minSDKVersion    = minSDK;
     this.targetSDKVersion = targetSDK;
 }
예제 #2
0
        public override void fixProblem()
        {
            var    settings           = new ImportantGradleSettings(path);
            var    leadingWhitespaces = "";
            string line;
            var    prevLine       = "";
            var    modifiedGradle = "";
            var    gradleScript   = new StreamReader(path);
            string multidexDependency;
            var    comparsionUnityVersionWith20182 =
                AppodealUnityUtils.compareVersions(Application.unityVersion, "2018.2");

            if (comparsionUnityVersionWith20182 < 0)
            {
                multidexDependency = MultidexActivator.GRADLE_COMPILE + MultidexActivator.GRADLE_MULTIDEX_DEPENDENCY;
            }
            else
            {
                multidexDependency = MultidexActivator.GRADLE_IMPLEMENTATION +
                                     MultidexActivator.GRADLE_MULTIDEX_DEPENDENCY;
            }

            while ((line = gradleScript.ReadLine()) != null)
            {
                if (!settings.multidexDependencyPresented && line.Contains(MultidexActivator.GRADLE_DEPENDENCIES))
                {
                    modifiedGradle += leadingWhitespaces + multidexDependency + Environment.NewLine;
                }

                if (!settings.multidexEnabled && line.Contains(MultidexActivator.GRADLE_APP_ID))
                {
                    modifiedGradle += leadingWhitespaces + MultidexActivator.GRADLE_MULTIDEX_ENABLE +
                                      Environment.NewLine;
                }

                if (settings.deprecatedProguardPresented && line.Contains(MultidexActivator.GRADLE_USE_PROGUARD))
                {
                    continue;
                }

                modifiedGradle    += line + Environment.NewLine;
                leadingWhitespaces = Regex.Match(line, "^\\s*").Value;
                if (line.Contains("repositories") && prevLine.Contains("allprojects") &&
                    !settings.googleRepositoryPresented)
                {
                    leadingWhitespaces += leadingWhitespaces;
                    modifiedGradle     += leadingWhitespaces + MultidexActivator.GRADLE_GOOGLE_REPOSITORY_COMPAT +
                                          Environment.NewLine;
                }

                prevLine = line;
            }

            gradleScript.Close();
            File.WriteAllText(path, modifiedGradle);
            AssetDatabase.ImportAsset(AppodealUnityUtils.absolute2Relative(path), ImportAssetOptions.ForceUpdate);
        }
예제 #3
0
 public ReplaceAppIdWithRealBundle(string manifest, string bundleId) : base(
         "Gradle build system disabled and ${applicationId} is presented in " +
         AppodealUnityUtils.absolute2Relative(manifest) +
         ". You can replace the line with your actual bundle id (default action) or enable gradle build system.",
         true)
 {
     this.manifest = manifest;
     this.bundleId = bundleId;
 }
예제 #4
0
        public override void fixProblem()
        {
            var fullManifestName = MultidexActivator.getCustomManifestPath();

            appNode.SetAttribute("name", ns, MultidexActivator.manifestMutlidexApp);
            Debug.Assert(appNode.OwnerDocument != null, "appNode.OwnerDocument != null");
            appNode.OwnerDocument.Save(fullManifestName);
            AssetDatabase.ImportAsset(AppodealUnityUtils.absolute2Relative(fullManifestName),
                                      ImportAssetOptions.ForceUpdate);
        }
예제 #5
0
        public override void fixProblem()
        {
            ImportantGradleSettings settings = new ImportantGradleSettings(path);
            string leadingWhitespaces        = "    ";
            string additionalWhiteSpaces     = "";
            string line;
            string modifiedGradle = "";

            StreamReader gradleScript = new StreamReader(path);

            while ((line = gradleScript.ReadLine()) != null)
            {
                if (line.Contains(MultidexActivator.GRAFLE_DEFAULT_CONFIG))
                {
                    if (!settings.compileOptions)
                    {
                        modifiedGradle += additionalWhiteSpaces + leadingWhitespaces +
                                          MultidexActivator.COMPILE_OPTIONS + Environment.NewLine;
                    }

                    if (!settings.sourceCapability)
                    {
                        modifiedGradle += leadingWhitespaces + leadingWhitespaces +
                                          MultidexActivator.GRADLE_SOURCE_CAPABILITY
                                          + MultidexActivator.GRADLE_JAVA_VERSION_1_8 + Environment.NewLine;
                    }

                    if (!settings.targetCapability)
                    {
                        modifiedGradle += leadingWhitespaces + leadingWhitespaces +
                                          MultidexActivator.GRADLE_TARGET_CAPATILITY
                                          + MultidexActivator.GRADLE_JAVA_VERSION_1_8 + Environment.NewLine;
                    }

                    if (!settings.targetCapability)
                    {
                        modifiedGradle += leadingWhitespaces + "}" + Environment.NewLine;
                    }

                    if (!settings.targetCapability)
                    {
                        modifiedGradle += leadingWhitespaces + Environment.NewLine;
                    }
                }

                modifiedGradle    += line + Environment.NewLine;
                leadingWhitespaces = Regex.Match(line, "^\\s*").Value;
            }

            gradleScript.Close();
            File.WriteAllText(path, modifiedGradle);
            AssetDatabase.ImportAsset(AppodealUnityUtils.absolute2Relative(path), ImportAssetOptions.ForceUpdate);
        }
예제 #6
0
        public override void fixProblem()
        {
            var defaultGradleTemplateFullName = MultidexActivator.getDefaultGradleTemplate();
            var destGradleScriptFullName      = AppodealUnityUtils.combinePaths(Application.dataPath,
                                                                                MultidexActivator.androidPluginsPath,
                                                                                MultidexActivator.gradleTemplateName);

            if (File.Exists(defaultGradleTemplateFullName))
            {
                File.Copy(defaultGradleTemplateFullName, destGradleScriptFullName);
            }

            AssetDatabase.ImportAsset(AppodealUnityUtils.absolute2Relative(destGradleScriptFullName),
                                      ImportAssetOptions.ForceUpdate);
            var settings = new ImportantGradleSettings(destGradleScriptFullName);

            if (!settings.isMultiDexAddedCompletely())
            {
                new EnableMultidexInGradle(destGradleScriptFullName).fixProblem();
            }
        }
예제 #7
0
        public override void fixProblem()
        {
            var doc = new XmlDocument();

            doc.Load(manifest);
            var manNode     = AppodealUnityUtils.XmlFindChildNode(doc, "manifest");
            var ns          = manNode.GetNamespaceOfPrefix("android");
            var usesSdkNode = (XmlElement)AppodealUnityUtils.XmlFindChildNode(manNode, "uses-sdk");

            if (usesSdkNode == null)
            {
                usesSdkNode = AppodealUnityUtils.XmlCreateTag(doc, "uses-sdk");
                manNode.AppendChild(usesSdkNode);
            }

            if (!usesSdkNode.HasAttribute("minSdkVersion", ns))
            {
                usesSdkNode.SetAttribute("minSdkVersion", ns, minSDKVersion);
            }
            usesSdkNode.SetAttribute("targetSdkVersion", ns, targetSDKVersion);
            doc.Save(manifest);
            AssetDatabase.ImportAsset(AppodealUnityUtils.absolute2Relative(manifest), ImportAssetOptions.ForceUpdate);
        }