コード例 #1
0
        public override void fixProblem()
        {
            //EditorApplication.applicationContentsPath is different for macos and win. need to fix to reach manifest and gradle templates
            string defaultGradleTemplateFullName = MultidexActivator.getDefaultGradleTemplate();

            string destGradleScriptFullName = AppodealUnityUtils.combinePaths(Application.dataPath,
                                                                              MultidexActivator.androidPluginsPath,
                                                                              MultidexActivator.gradleTemplateName);

            //Prefer to use build.gradle from the box. Just in case.
            if (File.Exists(defaultGradleTemplateFullName))
            {
                File.Copy(defaultGradleTemplateFullName, destGradleScriptFullName);
            }

            AssetDatabase.ImportAsset(AppodealUnityUtils.absolute2Relative(destGradleScriptFullName),
                                      ImportAssetOptions.ForceUpdate);

            //There are no multidex settings in default build.gradle but they can add that stuff.
            ImportantGradleSettings settings = new ImportantGradleSettings(destGradleScriptFullName);

            if (!settings.isMultiDexAddedCompletely())
            {
                new EnableMultidexInGradle(destGradleScriptFullName).fixProblem();
            }
        }
コード例 #2
0
        public override void fixProblem()
        {
            string fullManifestName = MultidexActivator.getCustomManifestPath();
            string defaultTemplate  = Path.Combine(EditorApplication.applicationContentsPath,
                                                   MultidexActivator.manifestDefaultTemplatePath);

            if (!File.Exists(defaultTemplate))
            {
                string unixAppContentsPath =
                    Path.GetDirectoryName(Path.GetDirectoryName(EditorApplication.applicationContentsPath));
                defaultTemplate = Path.Combine(unixAppContentsPath, MultidexActivator.manifestDefaultTemplatePath);
            }

            string appodealTemplate = AppodealUnityUtils.combinePaths(Application.dataPath,
                                                                      MultidexActivator.appodealTemplatesPath,
                                                                      MultidexActivator.manifestTemplateName);

            File.Copy(File.Exists(defaultTemplate) ? defaultTemplate : appodealTemplate, fullManifestName);
            AssetDatabase.ImportAsset(AppodealUnityUtils.absolute2Relative(fullManifestName),
                                      ImportAssetOptions.ForceUpdate);

            // There are no multidex activity in default AndroidManifest. But again, they can add it.
            XmlElement appNode = MultidexActivator.getApplicationNode(fullManifestName);
            string     ns      = appNode.GetNamespaceOfPrefix("android");

            if (!appNode.HasAttribute("name", ns))
            {
                new AddNameAttrubute(appNode, ns).fixProblem();
            }
        }
コード例 #3
0
ファイル: CheckerWindow.cs プロジェクト: Tetta/Circles
        private void init()
        {
            checkmark = EditorGUIUtility.IconContent("Collab").image;
            empty     = AppodealUnityUtils.makeColorTexture(checkmark.width, checkmark.height, Color.clear);

            steps = new List <CheckingStep>();
            steps.Add(new PlatformChecker());
            steps.Add(new MultidexActivator());
            steps.Add(new ManifestChecker());
            //steps.Add(new PlayServicesChecker());

            steps = steps.Where(step => step.isRequiredForPlatform(EditorUserBuildSettings.activeBuildTarget)).ToList();

            if (steps.Count > 0)
            {
                fixes = steps[currentStep].check();
                for (int i = 0; i < steps.Count; i++)
                {
                    if (i >= currentStep)
                    {
                        return;
                    }
                    steps[i].done = true;
                }
            }
        }
コード例 #4
0
ファイル: PlatformChecker.cs プロジェクト: Powertr1p/BP_Relax
        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);
        }
コード例 #5
0
        public override void fixProblem()
        {
            var fullManifestName = MultidexActivator.getCustomManifestPath();
            var defaultTemplate  = Path.Combine(EditorApplication.applicationContentsPath,
                                                MultidexActivator.manifestDefaultTemplatePath);

            if (!File.Exists(defaultTemplate))
            {
                var unixAppContentsPath =
                    Path.GetDirectoryName(Path.GetDirectoryName(EditorApplication.applicationContentsPath));
                Debug.Assert(unixAppContentsPath != null, nameof(unixAppContentsPath) + " != null");
                defaultTemplate = Path.Combine(unixAppContentsPath, MultidexActivator.manifestDefaultTemplatePath);
            }

            var appodealTemplate = AppodealUnityUtils.combinePaths(Application.dataPath,
                                                                   MultidexActivator.appodealTemplatesPath,
                                                                   MultidexActivator.manifestTemplateName);

            File.Copy(File.Exists(defaultTemplate) ? defaultTemplate : appodealTemplate, fullManifestName);
            AssetDatabase.ImportAsset(AppodealUnityUtils.absolute2Relative(fullManifestName),
                                      ImportAssetOptions.ForceUpdate);

            var appNode = MultidexActivator.getApplicationNode(fullManifestName);
            var ns      = appNode.GetNamespaceOfPrefix("android");

            if (!appNode.HasAttribute("name", ns))
            {
                new AddNameAttrubute(appNode, ns).fixProblem();
            }
        }
コード例 #6
0
        public override void fixProblem()
        {
            var manifestText = File.ReadAllText(manifest);

            manifestText = manifestText.Replace("${applicationId}", bundleId);
            File.WriteAllText(manifest, manifestText);
            AssetDatabase.ImportAsset(AppodealUnityUtils.absolute2Relative(manifest), ImportAssetOptions.ForceUpdate);
        }
コード例 #7
0
        public override void fixProblem()
        {
            ImportantGradleSettings settings = new ImportantGradleSettings(path);
            string       leadingWhitespaces  = "";
            string       line;
            string       prevLine       = "";
            string       modifiedGradle = "";
            StreamReader gradleScript   = new StreamReader(path);
            string       multidexDependency;
            int          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))
                {
                    //useProguard is deprecated
                    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);
        }
コード例 #8
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;
 }
コード例 #9
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;
     minSDKVersion    = minSDK;
     targetSDKVersion = targetSDK;
 }
コード例 #10
0
        public override void fixProblem()
        {
            string fullManifestName = MultidexActivator.getCustomManifestPath();

            appNode.SetAttribute("name", ns, MultidexActivator.manifestMutlidexApp);
            appNode.OwnerDocument.Save(fullManifestName);
            AssetDatabase.ImportAsset(AppodealUnityUtils.absolute2Relative(fullManifestName),
                                      ImportAssetOptions.ForceUpdate);
        }
コード例 #11
0
        public static XmlElement getApplicationNode(string manifestPath)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(manifestPath);
            XmlNode    manNode = AppodealUnityUtils.XmlFindChildNode(doc, "manifest");
            XmlElement appNode = (XmlElement)AppodealUnityUtils.XmlFindChildNode(manNode, "application");

            return(appNode);
        }
コード例 #12
0
        public static void PrepareProject(string buildPath)
        {
            Debug.Log("preparing your xcode project for appodeal");
            string projPath = Path.Combine(buildPath, "Unity-iPhone.xcodeproj/project.pbxproj");

            absoluteProjPath = Path.GetFullPath(buildPath);
            PBXProject project = new PBXProject();

            project.ReadFromString(File.ReadAllText(projPath));
            string target = project.TargetGuidByName("Unity-iPhone");

            AddProjectFrameworks(frameworkList, project, target, false);
            AddProjectFrameworks(weakFrameworkList, project, target, true);
            AddProjectLibs(platformLibs, project, target);
            project.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");

            //Major Xcode version version should be the same as that used by the native SDK developers.
            string xcodeVersion = AppodealUnityUtils.getXcodeVersion();

            if (xcodeVersion == null ||
                AppodealUnityUtils.compareVersions(xcodeVersion, minVersionToEnableBitcode) >= 0)
            {
                project.SetBuildProperty(target, "ENABLE_BITCODE", "YES");
            }
            else
            {
                project.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
            }

            project.AddBuildProperty(target, "LIBRARY_SEARCH_PATHS", "$(SRCROOT)/Libraries");
            project.AddBuildProperty(target, "LIBRARY_SEARCH_PATHS", "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)");
            project.AddBuildProperty(target, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
            project.AddBuildProperty(target, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks");
            project.SetBuildProperty(target, "SWIFT_VERSION", "4.0");

            //Adapters are archived in order not to exceed the 100 Mb limit on GitHub
            //Some users use GitHub with Unity Cloud Build
            string apdFolder    = "Adapters";
            string appodealPath = Path.Combine(Application.dataPath, "Appodeal");
            string adaptersPath = Path.Combine(appodealPath, apdFolder);

            if (Directory.Exists(adaptersPath))
            {
                foreach (string file in Directory.GetFiles(adaptersPath))
                {
                    if (Path.GetExtension(file).Equals(".zip"))
                    {
                        Debug.Log("unzipping:" + file);
                        AddAdaptersDirectory(apdFolder, project, target);
                    }
                }
            }

            File.WriteAllText(projPath, project.WriteToString());
        }
コード例 #13
0
        public override List <FixProblemInstruction> check()
        {
            var instructions = new List <FixProblemInstruction>();
            var manifests    =
                Directory.GetFiles(Application.dataPath, "AndroidManifest.xml", SearchOption.AllDirectories);
            var isGradleEnabled     = AppodealUnityUtils.isGradleEnabled();
            var bundleId            = AppodealUnityUtils.getApplicationId();
            var targetSDKVersionInt = AppodealUnityUtils.getAndroidTargetSDK();
            var minSDKVersionInt    = AppodealUnityUtils.getAndroidMinSDK();
            var targetSDKVersion    = targetSDKVersionInt.ToString();
            var minSDKVersion       = minSDKVersionInt.ToString();
            var sdkVersionsDefined  = targetSDKVersionInt > 0 && minSDKVersionInt > 0;

            if (!sdkVersionsDefined)
            {
                instructions.Add(new FixProblemInstruction(
                                     "Our plugin can't find android target sdk version: " + targetSDKVersionInt +
                                     ", or android min sdk version: " + minSDKVersionInt +
                                     ". Make sure that your project is properly configured.", false));
            }

            foreach (var manifest in manifests)
            {
                if (!manifest.Contains(Path.Combine("Plugins", "Android")))
                {
                    continue;
                }
                if (!isGradleEnabled)
                {
                    var manifestText = File.ReadAllText(manifest);
                    if (manifestText.Contains("${applicationId}"))
                    {
                        instructions.Add(new ReplaceAppIdWithRealBundle(manifest, bundleId));
                    }
                }

                if (!sdkVersionsDefined)
                {
                    continue;
                }
                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.HasAttribute("minSdkVersion", ns) ||
                    !usesSdkNode.HasAttribute("targetSdkVersion", ns))
                {
                    instructions.Add(new AddMinAndTargetSDK(manifest, minSDKVersion, targetSDKVersion));
                }
            }

            return(instructions);
        }
コード例 #14
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);
        }
コード例 #15
0
        static bool isMultidexEnabledSimpleCheck()
        {
            string path = getCustomGradleScriptPath();

            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }

            ImportantGradleSettings settings = new ImportantGradleSettings(path);

            return(settings.isMultidexEnabled() && AppodealUnityUtils.isGradleEnabled());
        }
コード例 #16
0
        private void EnableMultidex(string manifestPath, AndroidManifest androidManifest)
        {
#if UNITY_2019_3_OR_NEWER
            if (CheckContainsMultidex(manifestPath, manifestMutlidexApp))
            {
                androidManifest.RemoveMultiDexApplication();
            }
#else
            if (AppodealSettings.Instance.AndroidMultidex)
            {
                if (PlayerSettings.Android.minSdkVersion < AndroidSdkVersions.AndroidApiLevel21)
                {
                    androidManifest.AddMultiDexApplication();

                    if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
                    {
                        if (!AppodealUnityUtils.isGradleEnabled())
                        {
                            new EnableGradle().fixProblem();
                        }

                        var customGradeScript = GetCustomGradleScriptPath();
                        if (string.IsNullOrEmpty(customGradeScript) || !File.Exists(customGradeScript))
                        {
                            if (File.Exists(getDefaultGradleTemplate()))
                            {
                                new CopyGradleScriptAndEnableMultidex().fixProblem();
                            }
                        }
                        else
                        {
                            var settings = new ImportantGradleSettings(customGradeScript);
                            if (!settings.isMultiDexAddedCompletely())
                            {
                                new EnableMultidexInGradle(customGradeScript).fixProblem();
                            }

                            if (!settings.isJavaVersionIncluded())
                            {
                                new EnableJavaVersion(customGradeScript).fixProblem();
                            }
                        }
                    }
                }
            }
            else
            {
                androidManifest.RemoveMultiDexApplication();
            }
#endif
        }
コード例 #17
0
ファイル: PlatformChecker.cs プロジェクト: Powertr1p/BP_Relax
        private FixProblemInstruction checkAndGetInstruction(string relativePath, platforms platform)
        {
            EnablePluginForPlatform instr = null;
            var imp = AssetImporter.GetAtPath(relativePath) as PluginImporter;

            if (imp == null)
            {
                return(instr);
            }
            bool isChecked;

            switch (platform)
            {
            case platforms.any:
                isChecked = imp.GetCompatibleWithAnyPlatform();
                break;

            case platforms.editor:
                isChecked = imp.GetCompatibleWithEditor();
                break;

            case platforms.android:
                isChecked = imp.GetCompatibleWithPlatform(BuildTarget.Android);
                break;

            case platforms.ios:
                isChecked = imp.GetCompatibleWithPlatform(BuildTarget.iOS);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(platform), platform, null);
            }

            if (isChecked)
            {
                return(instr);
            }
            var desc = "Plugin " + relativePath + " should be enabled for platform: " + platform +
                       ".\n";

            if (relativePath.Contains(AppodealUnityUtils.combinePaths("Assets", "Plugins", "Android")))
            {
                desc +=
                    "If you wan't to exclude this network from your game, don't forget to add Appodeal.disableNetwork(networkname) before initialization.";
            }
            instr = new EnablePluginForPlatform(desc, true, relativePath, platform);

            return(instr);
        }
コード例 #18
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);
        }
コード例 #19
0
        public static string getDefaultGradleTemplate()
        {
            string defaultGradleTemplateFullName = AppodealUnityUtils.combinePaths(
                EditorApplication.applicationContentsPath,
                MultidexActivator.gradleDefaultTemplatePath,
                MultidexActivator.gradleTemplateName);

            if (!File.Exists(defaultGradleTemplateFullName))
            {
                string unixAppContentsPath =
                    Path.GetDirectoryName(Path.GetDirectoryName(EditorApplication.applicationContentsPath));
                defaultGradleTemplateFullName = AppodealUnityUtils.combinePaths(unixAppContentsPath,
                                                                                MultidexActivator.gradleDefaultTemplatePath,
                                                                                MultidexActivator.gradleTemplateName);
            }

            return(defaultGradleTemplateFullName);
        }
コード例 #20
0
        public static void PrepareProject(string buildPath)
        {
            Debug.Log("preparing your xcode project for appodeal");
            var projectPath = PBXProject.GetPBXProjectPath(buildPath);
            var project     = new PBXProject();

            project.ReadFromString(File.ReadAllText(projectPath));

#if UNITY_2019_3_OR_NEWER
            var target = project.GetUnityMainTargetGuid();
            var unityFrameworkTarget = project.GetUnityFrameworkTargetGuid();
#else
            var target = project.TargetGuidByName("Unity-iPhone");
#endif

            AddProjectFrameworks(frameworkList, project, target, false);
            AddProjectFrameworks(weakFrameworkList, project, target, true);
            AddProjectLibs(platformLibs, project, target);
            project.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");

            var xcodeVersion = AppodealUnityUtils.getXcodeVersion();
            if (xcodeVersion == null ||
                AppodealUnityUtils.compareVersions(xcodeVersion, minVersionToEnableBitcode) >= 0)
            {
                project.SetBuildProperty(target, "ENABLE_BITCODE", "YES");
            }
            else
            {
                project.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
            }

            project.AddBuildProperty(target, "LIBRARY_SEARCH_PATHS", "$(SRCROOT)/Libraries");
            project.AddBuildProperty(target, "LIBRARY_SEARCH_PATHS", "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)");
#if UNITY_2019_3_OR_NEWER
            project.AddBuildProperty(target, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
            project.AddBuildProperty(unityFrameworkTarget, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
#else
            project.AddBuildProperty(target, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
#endif
            project.AddBuildProperty(target, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks");
            project.SetBuildProperty(target, "SWIFT_VERSION", "4.0");

            File.WriteAllText(projectPath, project.WriteToString());
        }
コード例 #21
0
    public static void ReimportFolder(string path)
    {
        var files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);

        foreach (var file in files)
        {
            if (file.EndsWith(".DS_Store", System.StringComparison.Ordinal))
            {
                continue;
            }

            if (file.EndsWith(".meta", System.StringComparison.Ordinal))
            {
                continue;
            }

            AssetDatabase.ImportAsset(AppodealUnityUtils.FixSlashesInPath(file));
        }
    }
コード例 #22
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)
                {
                    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);
        }
コード例 #23
0
        public static string getDefaultGradleTemplate()
        {
            var defaultGradleTemplateFullName = AppodealUnityUtils.combinePaths(
                EditorApplication.applicationContentsPath,
                gradleDefaultTemplatePath,
                gradleTemplateName);

            if (File.Exists(defaultGradleTemplateFullName))
            {
                return(defaultGradleTemplateFullName);
            }
            var unixAppContentsPath =
                Path.GetDirectoryName(Path.GetDirectoryName(EditorApplication.applicationContentsPath));

            defaultGradleTemplateFullName = AppodealUnityUtils.combinePaths(unixAppContentsPath,
                                                                            gradleDefaultTemplatePath,
                                                                            gradleTemplateName);

            return(defaultGradleTemplateFullName);
        }
コード例 #24
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();
            }
        }
コード例 #25
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);
        }
コード例 #26
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);
        }
コード例 #27
0
        private static void setSelectedArchitectures(AppodealUnityUtils.AndroidArchitecture arch)
        {
            if (arch == AppodealUnityUtils.AndroidArchitecture.invalid)
            {
                EditorUtility.DisplayDialog("Architecture problems were found in the project",
                                            "For some reason it isn't possible to define selected architectures. Please check your settings. You also can check architectures manually",
                                            "Ok");
                return;
            }

            var selectedArches =
                new HashSet <AppodealUnityUtils.AndroidArchitecture>();

            foreach (AppodealUnityUtils.AndroidArchitecture a in Enum.GetValues(
                         typeof(AppodealUnityUtils.AndroidArchitecture)))
            {
                if ((arch & a) > 0)
                {
                    selectedArches.Add(a);
                }
            }

            var androidNativeDir   = AppodealUnityUtils.combinePaths(Application.dataPath, "Plugins", "Android");
            var nativeLibs         = Directory.GetDirectories(androidNativeDir);
            var needToUpdateAssets = false;
            var dialogWasShown     = false;

            foreach (var libPath in nativeLibs)
            {
                var
                         dir           = Path.GetFileName(libPath);
                var      archFullPaths =
                    new Dictionary <AppodealUnityUtils.AndroidArchitecture, string>();
                var archSafeFullPaths =
                    new Dictionary <AppodealUnityUtils.AndroidArchitecture, string>();
                var presentedArches =
                    new HashSet <AppodealUnityUtils.AndroidArchitecture>();
                var savedArches =
                    new HashSet <AppodealUnityUtils.AndroidArchitecture>();
                foreach (AppodealUnityUtils.AndroidArchitecture a in Enum.GetValues(
                             typeof(AppodealUnityUtils.AndroidArchitecture)))
                {
                    if (a == AppodealUnityUtils.AndroidArchitecture.invalid)
                    {
                        continue;
                    }
                    var fullPath = AppodealUnityUtils.combinePaths(androidNativeDir, dir, "libs", archDict[a]);
                    var safePath = AppodealUnityUtils.combinePaths(JNI_SAFE_PATH, dir);
                    archFullPaths.Add(a, fullPath);
                    archSafeFullPaths.Add(a, safePath);
                    if (Directory.Exists(fullPath))
                    {
                        presentedArches.Add(a);
                    }
                    if (Directory.Exists(AppodealUnityUtils.combinePaths(safePath, archDict[a])))
                    {
                        savedArches.Add(a);
                    }
                }

                if (presentedArches.Count == 0 && savedArches.Count == 0)
                {
                    continue;
                }

                foreach (AppodealUnityUtils.AndroidArchitecture a in Enum.GetValues(
                             typeof(AppodealUnityUtils.AndroidArchitecture)))
                {
                    if (a == AppodealUnityUtils.AndroidArchitecture.invalid)
                    {
                        continue;
                    }
                    if (selectedArches.Contains(a) == presentedArches.Contains(a))
                    {
                        continue;
                    }
                    if (presentedArches.Contains(a))
                    {
                        if (!Directory.Exists(archSafeFullPaths[a]))
                        {
                            Directory.CreateDirectory(archSafeFullPaths[a]);
                        }
                        Directory.Move(archFullPaths[a],
                                       AppodealUnityUtils.combinePaths(archSafeFullPaths[a], archDict[a]));
                        needToUpdateAssets = true;
                    }
                    else
                    {
                        if (savedArches.Contains(a))
                        {
                            Directory.Move(AppodealUnityUtils.combinePaths(archSafeFullPaths[a], archDict[a]),
                                           archFullPaths[a]);
                            needToUpdateAssets = true;
                        }
                        else
                        {
                            var message = "Plugin " + dir + " doesn't support the following architecture: " +
                                          archDict[a] +
                                          ". Building with this plugin can lead to crashes on devices with unsupported architectures.";
                            EditorUtility.DisplayDialog("Architecture problems were found in the project", message,
                                                        "Ok");
                            dialogWasShown = true;
                        }
                    }
                }
            }

            if (needToUpdateAssets)
            {
                AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
            }
            if (!dialogWasShown)
            {
                EditorUtility.DisplayDialog("Appodeal Notification",
                                            "Filtering finished. All possible problems resolved.",
                                            "Ok");
            }
        }
コード例 #28
0
        private void OnGUI()
        {
            if (steps == null)
            {
                init();
            }
            while ((fixes == null || fixes.Count == 0) && currentStep < steps.Count - 1)
            {
                steps[currentStep].done = true;
                currentStep++;
                fixes = steps[currentStep].check();
            }

            if ((fixes == null || fixes.Count == 0) && currentStep < steps.Count - 1)
            {
                steps[currentStep].done = true;
            }
            var w1           = position.width * 0.3f;
            var styleWhiteBG = new GUIStyle(GUI.skin.scrollView);

            GUILayout.Label(new GUIContent(
                                "This utility will check configuration only for the selected platform: " +
                                EditorUserBuildSettings.activeBuildTarget +
                                "\nIf you want to check your project for another platform, you should select it in the File > Build Settings.",
                                EditorGUIUtility.FindTexture("console.warnicon")));
            GUILayout.BeginHorizontal();
            scrollPositionSteps = GUILayout.BeginScrollView(scrollPositionSteps, styleWhiteBG, GUILayout.Width(w1));
            var selectedLabelStyle = new GUIStyle(GUI.skin.label)
            {
                normal = { background = AppodealUnityUtils.makeColorTexture(1, 1, Color.gray) }
            };

            foreach (var step in steps)
            {
                var stepContent = new GUIContent(step.getName(), step.done ? checkmark : empty);
                GUILayout.Label(stepContent,
                                step == steps[currentStep] && !step.done ? selectedLabelStyle : GUI.skin.label);
            }

            GUILayout.EndScrollView();

            GUILayout.BeginVertical();
            if (steps.Count > 0)
            {
                GUILayout.Label("Checking Appodeal Integration. Step " + (currentStep + 1) + "/" + steps.Count);

                scrollPositionFixes = GUILayout.BeginScrollView(scrollPositionFixes, styleWhiteBG);
                if (fixes == null || fixes.Count == 0)
                {
                    GUILayout.Label("Checking finished. Your project is ready to build.");
                }
                else
                {
                    foreach (var fix in fixes)
                    {
                        EditorGUI.BeginDisabledGroup(!fix.canBeResolvedAutomatically());
                        fix.checkedForResolve = GUILayout.Toggle(fix.checkedForResolve, fix.getDescription());
                        EditorGUI.EndDisabledGroup();
                    }
                }

                GUILayout.EndScrollView();
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Deselect All", GUILayout.Width(80)))
                {
                    setTogglesState(false);
                }
                if (GUILayout.Button("Select All", GUILayout.Width(80)))
                {
                    setTogglesState(true);
                }
                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.Label("Nothing to check for the selected platform.");
            }

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Close", GUILayout.Width(80)))
            {
                Close();
            }

            if (fixes != null && fixes.Count != 0)
            {
                if (GUILayout.Button("Fix Selected", GUILayout.Width(80)))
                {
                    foreach (var fix in fixes.Where(fix => fix.checkedForResolve))
                    {
                        fix.fixProblem();
                    }

                    fixes.Clear();
                }
            }

            GUILayout.EndHorizontal();
        }
コード例 #29
0
 public override void fixProblem()
 {
     AppodealUnityUtils.enableGradleBuildSystem();
 }
コード例 #30
0
 public static string getCustomManifestPath()
 {
     return(AppodealUnityUtils.combinePaths(Application.dataPath, androidPluginsPath, manifestTemplateName));
 }