예제 #1
0
        public override List <FixProblemInstruction> check()
        {
            var fixInstructions = new List <FixProblemInstruction>();

            foreach (var plugin in NATIVE_PLUGINS)
            {
                var absolutePluginPath    = AppodealUnityUtils.relative2Absolute(plugin.Key);
                var isFile                = File.Exists(absolutePluginPath);
                var isDirectory           = Directory.Exists(absolutePluginPath);
                var isAllDirectoryContent = absolutePluginPath.EndsWith("/*", false, null);
                if (!isFile && !isDirectory && !isAllDirectoryContent)
                {
                    var desc = "File or directory " + plugin.Key +
                               " does not exist. You should try to reimport Appodeal plugin.";
                    var instr = new FixProblemInstruction(desc, false);
                    fixInstructions.Add(instr);
                    continue;
                }

                if (!isFile && !isDirectory)
                {
                    continue;
                }
                {
                    var instr = checkAndGetInstruction(plugin.Key, plugin.Value);
                    if (instr != null)
                    {
                        fixInstructions.Add(instr);
                    }
                }
            }

            return(fixInstructions);
        }
예제 #2
0
        override public List <FixProblemInstruction> check()
        {
            List <FixProblemInstruction> fixInstructions = new List <FixProblemInstruction>();

            foreach (KeyValuePair <string, platforms> plugin in NATIVE_PLUGINS)
            {
                string absolutePuginPath     = AppodealUnityUtils.relative2Absolute(plugin.Key);
                bool   isFile                = File.Exists(absolutePuginPath);
                bool   isDirectory           = Directory.Exists(absolutePuginPath);
                bool   isAllDirectoryContent = absolutePuginPath.EndsWith("/*", false, null);
                if (!isFile && !isDirectory && !isAllDirectoryContent)
                {
                    string desc = "File or directory " + plugin.Key +
                                  " does not exist. You should try to reimport Appodeal plugin.";
                    FixProblemInstruction instr = new FixProblemInstruction(desc, false);
                    fixInstructions.Add(instr);
                    continue;
                }

                if (isFile || isDirectory)
                {
                    FixProblemInstruction instr = checkAndGetInstruction(plugin.Key, plugin.Value);
                    if (instr != null)
                    {
                        fixInstructions.Add(instr);
                    }
                }

                if (isAllDirectoryContent)
                {
                    //string[] nativeAndroidPlugins = Directory.GetFileSystemEntries(absolutePuginPath.TrimEnd("/*".ToCharArray()));
                    foreach (string folder in AppodealAssetsPostProcess.Plugins)
                    {
                        string pluginPath           = AppodealUnityUtils.combinePaths("Assets", "Plugins", "Android", folder);
                        FixProblemInstruction instr = checkAndGetInstruction(pluginPath, plugin.Value);
                        if (instr != null)
                        {
                            fixInstructions.Add(instr);
                        }
                    }
                }
            }

            return(fixInstructions);
        }
        public override List <FixProblemInstruction> check()
        {
            var fixInstructions = new List <FixProblemInstruction>();

            foreach (var plugin in NATIVE_PLUGINS)
            {
                var absolutePluginPath    = AppodealUnityUtils.relative2Absolute(plugin.Key);
                var isFile                = File.Exists(absolutePluginPath);
                var isDirectory           = Directory.Exists(absolutePluginPath);
                var isAllDirectoryContent = absolutePluginPath.EndsWith("/*", false, null);
                if (!isFile && !isDirectory && !isAllDirectoryContent)
                {
                    var desc = "File or directory " + plugin.Key +
                               " does not exist. You should try to reimport Appodeal plugin.";
                    var instr = new FixProblemInstruction(desc, false);
                    fixInstructions.Add(instr);
                    continue;
                }

                if (isFile || isDirectory)
                {
                    var instr = checkAndGetInstruction(plugin.Key, plugin.Value);
                    if (instr != null)
                    {
                        fixInstructions.Add(instr);
                    }
                }

                if (!isAllDirectoryContent)
                {
                    continue;
                }
                {
                    fixInstructions.AddRange(AppodealAssetsPostProcess.Plugins
                                             .Select(folder => AppodealUnityUtils.combinePaths("Assets", "Plugins", "Android", folder))
                                             .Select(pluginPath => checkAndGetInstruction(pluginPath, plugin.Value))
                                             .Where(instr => instr != null));
                }
            }

            return(fixInstructions);
        }
예제 #4
0
        override public List <FixProblemInstruction> check()
        {
            List <FixProblemInstruction> instructions = new List <FixProblemInstruction>();

            if (isNodexBuild() && EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
            {
                if (!AppodealUnityUtils.isGradleEnabled())
                {
                    if (!AppodealUnityUtils.isGradleAvailable())
                    {
                        FixProblemInstruction fix = new FixProblemInstruction(
                            "Gradle should be enabled if you use nodex version of Appodeal Plugin. " +
                            "But your version of Unity doesn't support gradle build system.Please update your Unity or use export to Eclipse or Android Studio.",
                            false);
                        instructions.Add(fix);
                        return(instructions);
                    }
                    else
                    {
                        instructions.Add(new EnableGradle());
                    }
                }

                string customGradeScript = getCustomGradleScriptPath();
                if (string.IsNullOrEmpty(customGradeScript) || !File.Exists(customGradeScript))
                {
                    if (File.Exists(getDefaultGradleTemplate()))
                    {
                        instructions.Add(new CopyGradleScriptAndEnableMultidex());
                    }
                    else
                    {
                        FixProblemInstruction instr = new FixProblemInstruction(
                            "Tere is no build.gradle template in your Unity. " +
                            "Please ensure that your copy of Unity isn't crashed and contact Appodeal Support team.",
                            false);
                        instructions.Add(instr);
                        return(instructions);
                    }
                }
                else
                {
                    ImportantGradleSettings settings = new ImportantGradleSettings(customGradeScript);
                    if (!settings.isMultiDexAddedCompletely())
                    {
                        instructions.Add(new EnableMultidexInGradle(customGradeScript));
                    }

                    if (!settings.isJavaVersionIncluded())
                    {
                        instructions.Add(new EnableJavaVersion(customGradeScript));
                    }
                }

                string customManifestPath = getCustomManifestPath();
                if (string.IsNullOrEmpty(customManifestPath) || !File.Exists(customManifestPath))
                {
                    instructions.Add(new CopyManifestTemplateAndAddNameAttribute());
                }
                else
                {
                    XmlElement appNode = getApplicationNode(customManifestPath);
                    string     ns      = appNode.GetNamespaceOfPrefix("android");
                    if (!appNode.HasAttribute("name", ns))
                    {
                        instructions.Add(new AddNameAttrubute(appNode, ns));
                    }
                    else
                    {
                        if (appNode.GetAttribute("name", ns) != manifestMutlidexApp)
                        {
                            FixProblemInstruction fix = new FixProblemInstruction(
                                "We found that you use custom Application class in this project. " +
                                "Please ensure that your application class meets the multidex requirements (see the official android multiex documentation).",
                                false);
                            instructions.Add(fix);
                        }
                    }
                }
            }
            else if (!isNodexBuild() && isMultidexEnabledSimpleCheck() &&
                     EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
            {
                FixProblemInstruction fix = new FixProblemInstruction(
                    "We found that multidex is enabled in your project. To avoid possible problems please " +
                    "replace current version of Appodeal plugin with nodex version.", false);
                instructions.Add(fix);
            }

            return(instructions);
        }
예제 #5
0
        public override List <FixProblemInstruction> check()
        {
            List <FixProblemInstruction> instructions = new List <FixProblemInstruction>();
            string appodealDependenciesFile           = getAppodealDependenciesFile();
            Regex  reAar = new Regex(@"play-services.+-(?<version>\d+\.\d+(\.\d+)*)");

            string[] aarFiles = getPlayServicesAarFiles();
            foreach (string file in aarFiles)
            {
                foreach (string service in requiredServices.Keys)
                {
                    if (file.Contains(service))
                    {
                        Match m = reAar.Match(file);
                        if (m.Success)
                        {
                            requiredServices[service].Add(m.Value);
                        }
                        else
                        {
                            FixProblemInstruction instr = new FixProblemInstruction(
                                "Play service without specified version found. " +
                                "Please specify version to be able to resolve possible conflicts automatically." + file,
                                false);
                            instructions.Add(instr);
                            return(instructions);
                        }
                    }
                }
            }

            HashSet <string> absentServices = new HashSet <string>();
            HashSet <string> allVersions    = new HashSet <string>();

            foreach (KeyValuePair <string, HashSet <string> > service in requiredServices)
            {
                if (service.Value.Count == 0)
                {
                    absentServices.Add(service.Key);
                }

                allVersions.UnionWith(service.Value);
            }

            DependenciesParser deps = new DependenciesParser(getAllDependenciesFiles());

            absentServices.RemoveWhere(s => deps.foundServices.Contains(s));
            if (absentServices.Count > 0)
            {
                string absent = string.Join(",", absentServices.ToArray());
                FixProblemInstruction instr =
                    new FixProblemInstruction("Some required Play Services are absent in your project: " + absent,
                                              false);
                instructions.Add(instr);
                return(instructions);
            }

            HashSet <string> allVersionsInDependencies = new HashSet <string>();

            foreach (KeyValuePair <string, HashSet <string> > kv in deps.playServicesVersions)
            {
                if (kv.Value.Count > 1)
                {
                    FixProblemInstruction instr = new FixProblemInstruction(
                        "Two or more different versions of play services are presented in " +
                        kv.Key + ". Please contact the plugin developers to clarify what version is required.", false);
                    instructions.Add(instr);
                    return(instructions);
                }

                allVersionsInDependencies.UnionWith(kv.Value);
            }

            if (allVersions.Count == 0)
            {
                if (allVersionsInDependencies.Count == 0)
                {
                    FixProblemInstruction instr = new FixProblemInstruction(
                        "There is no Google Play Services in the project. It's a essential condition if you want to use Appodeal plugin. Please visit our web site to get more information.",
                        false);
                    instructions.Add(instr);
                    return(instructions);
                }
                else if (allVersionsInDependencies.Count == 1)
                {
                    //and at least some of required services are in xml
                }

                //Надо узнать, есть ли зависимости в градле и правильные ли они или xml прежде чем что-то предлагать
                //В xml - ресолвим
                //В градл - вообще все норм (при условии отсуствия конфликтов)
            }
            else if (allVersions.Count == 2)
            {
                //1 Зависимости от разных xml (если один из них - AppodealDependencies, то меняем в нем; если нет, то придется ограничится предупреждением)
                //2 Одни - зависимость от xml, другие просто положены каким-то плагином (Если есть AppodealDependencies, то меняем в нем? иначе предупреждение)
                //3 Все напрямую распространялись плагинами (предупреждение)
            }
            else if (allVersions.Count > 2)
            {
                FixProblemInstruction instr = new FixProblemInstruction(
                    "There are three or more different versions of google play services " +
                    "in your project: " + allVersions + ". It's not possible to resolve this conflict automatically. " +
                    "Try to update all plugins in your project and run the checker again.", false);
                instructions.Add(instr);
                return(instructions);
            }

            //What if aar file is a result of JarResolver work? We can change version in resolver and aar version will be changed too
            //On the other hand, it can be just an aar. And we can't change anything in this case.

            return(instructions);
        }
예제 #6
0
        public override List <FixProblemInstruction> check()
        {
            var instructions = new List <FixProblemInstruction>();
            var reAar        = new Regex(@"play-services.+-(?<version>\d+\.\d+(\.\d+)*)");

            var aarFiles = getPlayServicesAarFiles();

            foreach (var file in aarFiles)
            {
                foreach (var service in requiredServices.Keys)
                {
                    if (!file.Contains(service))
                    {
                        continue;
                    }
                    var m = reAar.Match(file);
                    if (m.Success)
                    {
                        requiredServices[service].Add(m.Value);
                    }
                    else
                    {
                        var instr = new FixProblemInstruction(
                            "Play service without specified version found. " +
                            "Please specify version to be able to resolve possible conflicts automatically." + file,
                            false);
                        instructions.Add(instr);
                        return(instructions);
                    }
                }
            }

            var absentServices = new HashSet <string>();
            var allVersions    = new HashSet <string>();

            foreach (var service in requiredServices)
            {
                if (service.Value.Count == 0)
                {
                    absentServices.Add(service.Key);
                }

                allVersions.UnionWith(service.Value);
            }

            var deps = new DependenciesParser(getAllDependenciesFiles());

            absentServices.RemoveWhere(s => deps.foundServices.Contains(s));
            if (absentServices.Count > 0)
            {
                var absent = string.Join(",", absentServices.ToArray());
                var instr  =
                    new FixProblemInstruction("Some required Play Services are absent in your project: " + absent,
                                              false);
                instructions.Add(instr);
                return(instructions);
            }

            var allVersionsInDependencies = new HashSet <string>();

            foreach (var kv in deps.playServicesVersions)
            {
                if (kv.Value.Count > 1)
                {
                    var instr = new FixProblemInstruction(
                        "Two or more different versions of play services are presented in " +
                        kv.Key + ". Please contact the plugin developers to clarify what version is required.", false);
                    instructions.Add(instr);
                    return(instructions);
                }

                allVersionsInDependencies.UnionWith(kv.Value);
            }

            switch (allVersions.Count)
            {
            case 0:
            {
                switch (allVersionsInDependencies.Count)
                {
                case 0:
                {
                    var instr = new FixProblemInstruction(
                        "There is no Google Play Services in the project. It's a essential condition if you want to use Appodeal plugin. Please visit our web site to get more information.",
                        false);
                    instructions.Add(instr);
                    return(instructions);
                }

                case 1:
                    break;
                }

                break;
            }

            case 2:
                break;

            default:
            {
                if (allVersions.Count > 2)
                {
                    var instr = new FixProblemInstruction(
                        "There are three or more different versions of google play services " +
                        "in your project: " + allVersions + ". It's not possible to resolve this conflict automatically. " +
                        "Try to update all plugins in your project and run the checker again.", false);
                    instructions.Add(instr);
                    return(instructions);
                }

                break;
            }
            }

            return(instructions);
        }