public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Processing native plugins");
     }
     this._stagingArea = context.Get<string>("StagingArea");
     string str = context.Get<string>("TargetLibrariesFolder");
     context.Set<bool>("HasJarPlugins", false);
     this._pluginsFolder = Path.Combine(this._stagingArea, "plugins");
     Directory.CreateDirectory(this._pluginsFolder);
     this._aarFolder = Path.Combine(this._stagingArea, "aar");
     Directory.CreateDirectory(this._aarFolder);
     BuildTarget target = context.Get<BuildTarget>("BuildTarget");
     foreach (PluginDesc desc in PluginImporter.GetExtensionPlugins(target))
     {
         string pluginTargetCPU = desc.architecture.ToString();
         this.ProcessPlugin(context, desc.pluginPath, pluginTargetCPU);
     }
     foreach (PluginImporter importer in PluginImporter.GetImporters(target))
     {
         string assetPath = importer.assetPath;
         if (Directory.Exists(assetPath) && AndroidLibraries.IsAndroidLibraryProject(assetPath))
         {
             FileUtil.CopyDirectoryRecursiveForPostprocess(assetPath, Path.Combine(str, Path.GetFileName(assetPath)), true);
         }
         this.UpgradePluginCPU(importer, target);
         string platformData = importer.GetPlatformData(target, "CPU");
         this.ProcessPlugin(context, assetPath, platformData);
     }
 }
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Setting up target contents directory");
            }
            string      str    = context.Get <string>("StagingArea");
            BuildTarget target = context.Get <BuildTarget>("BuildTarget");
            string      dir    = Path.Combine(str, "android-libraries");

            FileUtil.CreateOrCleanDirectory(dir);
            context.Set <string>("TargetLibrariesFolder", dir);
            Directory.CreateDirectory(Path.Combine(str, "bin"));
            bool useAPKExpansionFiles = PlayerSettings.Android.useAPKExpansionFiles;

            context.Set <bool>("UseObb", useAPKExpansionFiles);
            context.Set <int>("GearVRMinSdkVersion", 0x13);
            string path = Path.Combine(BuildPipeline.GetBuildToolsDirectory(target), "fastzip");

            if (!File.Exists(path))
            {
                path = Path.Combine(BuildPipeline.GetBuildToolsDirectory(target), "fastzip.exe");
            }
            context.Set <string>("FastzipExe", path);
            bool flag2 = File.Exists(path);

            context.Set <bool>("UseFastzip", flag2);
            if (PlayerSettings.Android.androidTVCompatibility && !this.IsOrientationAndroidTVCompatible())
            {
                Debug.LogWarning("The orientation specified is not compatible with Android TV.\nPlease select Landscape or AutoRotation with Landscape enabled orientation, or disable Android TV compatibility in Player Settings.");
            }
        }
Exemple #3
0
        public void Execute(PostProcessorContext context)
        {
            this._developmentPlayer = context.Get <bool>("DevelopmentPlayer");
            this._stagingArea       = context.Get <string>("StagingArea");
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Merging AndroidManifest.xml files");
            }
            string manifest = this.CopyMainManifest(context, Path.Combine(this._stagingArea, "AndroidManifest-main.xml"));

            this.InjectBundleAndSDKVersion(context, manifest);
            string str2 = this.MergeManifests(context, Path.Combine(this._stagingArea, "AndroidManifest.xml"), manifest);

            context.Set <string>("ManifestName", str2);
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Patching manifest");
            }
            string str3 = this.PatchManifest(context, str2);

            context.Set <string>("PackageName", str3);
            if (new AndroidManifest(str2).GetActivityWithLaunchIntent().Length == 0)
            {
                Debug.LogWarning("No activity found in the manifest with action MAIN and category LAUNCHER.\nYour application may not start correctly.");
            }
            this.ThrowIfInvalid(str3);
        }
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Processing native plugins");
            }
            this._stagingArea = context.Get <string>("StagingArea");
            string str = context.Get <string>("TargetLibrariesFolder");

            context.Set <bool>("HasJarPlugins", false);
            this._pluginsFolder = Path.Combine(this._stagingArea, "plugins");
            Directory.CreateDirectory(this._pluginsFolder);
            this._aarFolder = Path.Combine(this._stagingArea, "aar");
            Directory.CreateDirectory(this._aarFolder);
            BuildTarget target = context.Get <BuildTarget>("BuildTarget");

            foreach (PluginDesc desc in PluginImporter.GetExtensionPlugins(target))
            {
                string pluginTargetCPU = desc.architecture.ToString();
                this.ProcessPlugin(context, desc.pluginPath, pluginTargetCPU);
            }
            foreach (PluginImporter importer in PluginImporter.GetImporters(target))
            {
                string assetPath = importer.assetPath;
                if (Directory.Exists(assetPath) && AndroidLibraries.IsAndroidLibraryProject(assetPath))
                {
                    FileUtil.CopyDirectoryRecursiveForPostprocess(assetPath, Path.Combine(str, Path.GetFileName(assetPath)), true);
                }
                this.UpgradePluginCPU(importer, target);
                string platformData = importer.GetPlatformData(target, "CPU");
                this.ProcessPlugin(context, assetPath, platformData);
            }
        }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Copying unity libraries");
     }
     this._stagingArea = context.Get<string>("StagingArea");
     this._playerPackage = context.Get<string>("PlayerPackage");
     AndroidTargetDevice device = context.Get<AndroidTargetDevice>("TargetDevice");
     switch (device)
     {
         case AndroidTargetDevice.FAT:
         case AndroidTargetDevice.ARMv7:
             this.PrepareNativeUnityLibs(context, "armeabi-v7a");
             break;
     }
     if ((device == AndroidTargetDevice.FAT) || (device == AndroidTargetDevice.x86))
     {
         this.PrepareNativeUnityLibs(context, "x86");
     }
     string[] components = new string[] { this._playerPackage, "Apk", "assets" };
     FileUtil.CopyDirectoryRecursive(Paths.Combine(components), Path.Combine(this._stagingArea, "assets"), true);
     string[] textArray2 = new string[] { this._playerPackage, "Apk", "res" };
     FileUtil.CopyDirectoryRecursive(Paths.Combine(textArray2), Path.Combine(this._stagingArea, "res"), true);
 }
Exemple #6
0
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Copying unity libraries");
            }
            this._stagingArea   = context.Get <string>("StagingArea");
            this._playerPackage = context.Get <string>("PlayerPackage");
            AndroidTargetDevice device = context.Get <AndroidTargetDevice>("TargetDevice");

            switch (device)
            {
            case AndroidTargetDevice.FAT:
            case AndroidTargetDevice.ARMv7:
                this.PrepareNativeUnityLibs(context, "armeabi-v7a");
                break;
            }
            if ((device == AndroidTargetDevice.FAT) || (device == AndroidTargetDevice.x86))
            {
                this.PrepareNativeUnityLibs(context, "x86");
            }
            string[] components = new string[] { this._playerPackage, "Apk", "assets" };
            FileUtil.CopyDirectoryRecursive(Paths.Combine(components), Path.Combine(this._stagingArea, "assets"), true);
            string[] textArray2 = new string[] { this._playerPackage, "Apk", "res" };
            FileUtil.CopyDirectoryRecursive(Paths.Combine(textArray2), Path.Combine(this._stagingArea, "res"), true);
        }
 public static string GetVariationsDirectory(PostProcessorContext context)
 {
     ScriptingImplementation implementation = context.Get<ScriptingImplementation>("ScriptingBackend");
     string str = context.Get<string>("PlayerPackage");
     bool flag = context.Get<bool>("DevelopmentPlayer");
     string[] components = new string[] { str, "Variations", (implementation != ScriptingImplementation.IL2CPP) ? "mono" : "il2cpp", !flag ? "Release" : "Development" };
     return Paths.Combine(components);
 }
        public static string GetVariationsDirectory(PostProcessorContext context)
        {
            ScriptingImplementation implementation = context.Get <ScriptingImplementation>("ScriptingBackend");
            string str  = context.Get <string>("PlayerPackage");
            bool   flag = context.Get <bool>("DevelopmentPlayer");

            string[] components = new string[] { str, "Variations", (implementation != ScriptingImplementation.IL2CPP) ? "mono" : "il2cpp", !flag ? "Release" : "Development" };
            return(Paths.Combine(components));
        }
Exemple #9
0
 public void Execute(PostProcessorContext context)
 {
     bool flag = context.Get<bool>("UseFastzip");
     bool flag2 = context.Get<bool>("ExportAndroidProject");
     if (flag && !flag2)
     {
         this.CreatePackagesWithFastzip(context);
     }
 }
Exemple #10
0
        public void Execute(PostProcessorContext context)
        {
            bool flag  = context.Get <bool>("UseFastzip");
            bool flag2 = context.Get <bool>("ExportAndroidProject");

            if (flag && !flag2)
            {
                this.CreatePackagesWithFastzip(context);
            }
        }
 private string CopyMainManifest(PostProcessorContext context, string target)
 {
     string str = context.Get<string>("AndroidPluginsPath");
     string str2 = context.Get<string>("PlayerPackage");
     string path = Path.Combine(str, "AndroidManifest.xml");
     if (!File.Exists(path))
     {
         string[] components = new string[] { str2, "Apk", "AndroidManifest.xml" };
         path = Paths.Combine(components);
     }
     return new AndroidManifest(path).SaveAs(target);
 }
Exemple #12
0
        private string CopyMainManifest(PostProcessorContext context, string target)
        {
            string str  = context.Get <string>("AndroidPluginsPath");
            string str2 = context.Get <string>("PlayerPackage");
            string path = Path.Combine(str, "AndroidManifest.xml");

            if (!File.Exists(path))
            {
                string[] components = new string[] { str2, "Apk", "AndroidManifest.xml" };
                path = Paths.Combine(components);
            }
            return(new AndroidManifest(path).SaveAs(target));
        }
 public void Execute(PostProcessorContext context)
 {
     this._packageName       = context.Get <string>("PackageName");
     this._installPath       = context.Get <string>("InstallPath");
     this._device            = context.Get <AndroidDevice>("AndroidDevice");
     this._developmentPlayer = context.Get <bool>("DevelopmentPlayer");
     this.UploadAPK(false);
     if (context.Get <bool>("UseObb"))
     {
         this.UploadOBB();
     }
     this.StartApplication(context);
 }
Exemple #14
0
        public void Execute(PostProcessorContext context)
        {
            string str = context.Get <string>("StagingArea");

            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Preparing and unpacking AAR plugins");
            }
            string str2 = Path.Combine(str, "aar");
            string path = Path.Combine(str, "android-libraries");

            Directory.CreateDirectory(path);
            string[] strArray = AndroidFileLocator.Find(Path.Combine(str2, "*.aar"));
            foreach (string str4 in strArray)
            {
                string fileName = Path.GetFileName(str4);
                string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(str4);
                string str7 = Path.Combine(path, fileNameWithoutExtension);
                if (Directory.Exists(str7))
                {
                    CancelPostProcess.AbortBuild("Build failure", "Plugin conflict detected for file " + fileName, null);
                }
                Directory.CreateDirectory(str7);
                TasksCommon.Exec(AndroidJavaTools.jarPath, "xf \"" + str4 + "\"", str7, "Error unpacking file " + fileName, 0);
                string str8 = Path.Combine(str7, "libs");
                Directory.CreateDirectory(str8);
                FileUtil.MoveFileOrDirectory(Path.Combine(str7, "classes.jar"), Path.Combine(str8, "classes.jar"));
                string str9 = Path.Combine(str7, "jni");
                if (Directory.Exists(str9))
                {
                    string str10 = Path.Combine(str7, "libs");
                    foreach (string str11 in Directory.GetDirectories(str9, "*"))
                    {
                        string to = Path.Combine(str10, FileUtil.RemovePathPrefix(str11, str9));
                        FileUtil.MoveFileOrDirectory(str11, to);
                    }
                }
                string str13 = Path.Combine(str7, "src");
                if (!Directory.Exists(str13))
                {
                    Directory.CreateDirectory(str13);
                }
                if (!File.Exists(Path.Combine(str7, AndroidLibraries.ProjectPropertiesFileName)))
                {
                    int num3 = context.Get <int>("TargetSDKVersion");
                    File.WriteAllText(Path.Combine(str7, AndroidLibraries.ProjectPropertiesFileName), $"android.library=true

target=android-{num3}");
                }
            }
        }
 public void Execute(PostProcessorContext context)
 {
     if (!context.Get <bool>("UseFastzip"))
     {
         bool flag2 = context.Get <bool>("ExportAndroidProject");
         this._stagingArea = context.Get <string>("StagingArea");
         bool flag3 = context.Get <bool>("UseObb");
         if (!flag2)
         {
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building streaming package");
             }
             if (Directory.Exists(Path.Combine(this._stagingArea, "raw")))
             {
                 this.AAPTPack(context, "raw.ap_", "raw", false);
             }
         }
         if (flag3)
         {
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building expansion asset package (OBB)");
             }
             this.AAPTPack(context, "obb.ap_", "obbassets", true);
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building expansion streaming package (OBB)");
             }
             if (Directory.Exists(Path.Combine(this._stagingArea, "rawobb")))
             {
                 this.AAPTPack(context, "rawobb.ap_", "rawobb", false);
             }
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Creating APK expansion package (OBB)");
             }
             this.BuildObb(context);
         }
         if (!flag2)
         {
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building asset package");
             }
             this.AAPTPack(context, "assets.ap_", "assets", true);
         }
     }
 }
 public void Execute(PostProcessorContext context)
 {
     if (!context.Get<bool>("UseFastzip"))
     {
         bool flag2 = context.Get<bool>("ExportAndroidProject");
         this._stagingArea = context.Get<string>("StagingArea");
         bool flag3 = context.Get<bool>("UseObb");
         if (!flag2)
         {
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building streaming package");
             }
             if (Directory.Exists(Path.Combine(this._stagingArea, "raw")))
             {
                 this.AAPTPack(context, "raw.ap_", "raw", false);
             }
         }
         if (flag3)
         {
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building expansion asset package (OBB)");
             }
             this.AAPTPack(context, "obb.ap_", "obbassets", true);
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building expansion streaming package (OBB)");
             }
             if (Directory.Exists(Path.Combine(this._stagingArea, "rawobb")))
             {
                 this.AAPTPack(context, "rawobb.ap_", "rawobb", false);
             }
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Creating APK expansion package (OBB)");
             }
             this.BuildObb(context);
         }
         if (!flag2)
         {
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building asset package");
             }
             this.AAPTPack(context, "assets.ap_", "assets", true);
         }
     }
 }
Exemple #17
0
        private string MergeManifests(PostProcessorContext context, string targetManifest, string mainManifest)
        {
            AndroidSDKTools  tools     = context.Get <AndroidSDKTools>("SDKTools");
            AndroidLibraries libraries = context.Get <AndroidLibraries>("AndroidLibraries");
            bool             flag      = context.Get <bool>("ExportAndroidProject");

            string[] manifestFiles = libraries.GetManifestFiles();
            if (!flag && (manifestFiles.Length > 0))
            {
                tools.MergeManifests(targetManifest, mainManifest, manifestFiles, null);
                return(targetManifest);
            }
            FileUtil.CopyFileOrDirectory(mainManifest, targetManifest);
            return(targetManifest);
        }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Processing user-provided Android resources");
     }
     string str = context.Get<string>("AndroidPluginsPath");
     string str2 = context.Get<string>("TargetLibrariesFolder");
     string path = Path.Combine(str, "res");
     if (Directory.Exists(path))
     {
         Debug.LogWarning("OBSOLETE - Providing Android resources in Assets/Plugins/Android/res is deprecated, please move your resources to an Android Library. See \"Building Plugins for Android\" section of the Manual.");
         this.GenerateAndroidLibraryWithResources(context, path, Path.Combine(str2, "unity-android-resources"));
     }
 }
 public void Execute(PostProcessorContext context)
 {
     this._stagingArea = context.Get<string>("StagingArea");
     this._packageName = context.Get<string>("PackageName");
     this._useObb = context.Get<bool>("UseObb");
     if (context.Get<bool>("AutoRunPlayer"))
     {
         this.UploadAndStartPlayer(context, false);
     }
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Moving final Android package");
     }
     this.MoveFinalAndroidPackage(context);
 }
Exemple #20
0
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Processing user-provided Android resources");
     }
     string str = context.Get<string>("AndroidPluginsPath");
     string str2 = context.Get<string>("TargetLibrariesFolder");
     string path = Path.Combine(str, "res");
     if (Directory.Exists(path))
     {
         Debug.LogWarning("OBSOLETE - Providing Android resources in Assets/Plugins/Android/res is deprecated, please move your resources to an Android Library. See \"Building Plugins for Android\" section of the Manual.");
         this.GenerateAndroidLibraryWithResources(context, path, Path.Combine(str2, "unity-android-resources"));
     }
 }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Building");
     }
     this._playerPackage = context.Get<string>("PlayerPackage");
     string stagingArea = context.Get<string>("StagingArea");
     AndroidLibraries androidLibraries = context.Get<AndroidLibraries>("AndroidLibraries");
     string packageName = context.Get<string>("PackageName");
     bool useObb = context.Get<bool>("UseObb");
     int platformApiLevel = context.Get<int>("PlatformApiLevel");
     int num2 = context.Get<int>("ProjectType");
     string googleBuildTools = context.Get<AndroidSDKTools>("SDKTools").BuildToolsVersion(null);
     if (num2 != 1)
     {
         throw new UnityException("Illegal project type: " + num2);
     }
     string[] components = new string[] { this._playerPackage, "Source" };
     string[] textArray2 = new string[] { TasksCommon.GetClassDirectory(context), "classes.jar" };
     AndroidProjectExport.ExportGradle(Paths.Combine(components), Paths.Combine(textArray2), BuildPipeline.GetBuildToolsDirectory(BuildTarget.Android), stagingArea, androidLibraries, null, packageName, PlayerSettings.productName, platformApiLevel, googleBuildTools, useObb);
     bool flag2 = PlayerSettings.Android.keyaliasName.Length != 0;
     bool flag3 = context.Get<bool>("DevelopmentPlayer");
     string sourceFileName = "";
     string task = "";
     string[] textArray3 = new string[] { stagingArea, "gradleOut" };
     string workingdir = Paths.Combine(textArray3);
     if (flag3)
     {
         task = "assembleDebug";
         string[] textArray4 = new string[] { workingdir, "build", "outputs", "apk", "gradleOut-debug.apk" };
         sourceFileName = Paths.Combine(textArray4);
     }
     else
     {
         if (!flag2)
         {
             CancelPostProcess.AbortBuild("Build Failure", "Release builds have to be signed when using Gradle");
             return;
         }
         task = "assembleRelease";
         string[] textArray5 = new string[] { workingdir, "build", "outputs", "apk", "gradleOut-release.apk" };
         sourceFileName = Paths.Combine(textArray5);
     }
     GradleWrapper.Run(workingdir, task, delegate (string task) {
         if (((this.OnProgress != null) && (task != "")) && (task[0] == ':'))
         {
             this.OnProgress(this, "Task " + task.Substring(1));
         }
     });
     string[] textArray6 = new string[] { stagingArea, "Package.apk" };
     File.Move(sourceFileName, Paths.Combine(textArray6));
 }
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Building");
            }
            string str    = context.Get <string>("StagingArea");
            int    system = context.Get <int>("ProjectType");

            if (system != 1)
            {
                throw new UnityException("Illegal project type: " + system);
            }
            AndroidProjectExport.Create(system).Export(context, null);
            bool   flag           = PlayerSettings.Android.keyaliasName.Length != 0;
            bool   flag2          = context.Get <bool>("DevelopmentPlayer");
            string sourceFileName = "";
            string task           = "";

            string[] components = new string[] { "Temp", "gradleOut" };
            string   workingdir = Paths.Combine(components);

            if (flag2 || Unsupported.IsDeveloperBuild())
            {
                task = "assembleDebug";
                string[] textArray2 = new string[] { workingdir, "build", "outputs", "apk", "gradleOut-debug.apk" };
                sourceFileName = Paths.Combine(textArray2);
            }
            else
            {
                if (!flag)
                {
                    CancelPostProcess.AbortBuild("Build Failure", "Release builds have to be signed when using Gradle", null);
                    return;
                }
                task = "assembleRelease";
                string[] textArray3 = new string[] { workingdir, "build", "outputs", "apk", "gradleOut-release.apk" };
                sourceFileName = Paths.Combine(textArray3);
            }
            GradleWrapper.Run(workingdir, task, delegate(string task) {
                if (((this.OnProgress != null) && (task != "")) && (task[0] == ':'))
                {
                    this.OnProgress(this, "Task " + task.Substring(1));
                }
            });
            string[] textArray4 = new string[] { str, "Package.apk" };
            File.Move(sourceFileName, Paths.Combine(textArray4));
        }
 private void MoveFinalAndroidPackage(PostProcessorContext context)
 {
     string path = context.Get<string>("InstallPath");
     if (Directory.Exists(path))
     {
         try
         {
             Directory.Delete(path);
         }
         catch (IOException)
         {
             CancelPostProcess.AbortBuild("Unable to create new apk!", string.Format("Unable to write target apk because {0} is a non-empty directory", path));
         }
     }
     else
     {
         File.Delete(path);
         if (File.Exists(path))
         {
             CancelPostProcess.AbortBuild("Unable to delete old apk!", string.Format("Target apk could not be overwritten: {0}", path));
         }
     }
     FileUtil.MoveFileOrDirectory(Path.Combine(this._stagingArea, "Package.apk"), path);
     if (!File.Exists(path))
     {
         CancelPostProcess.AbortBuild("Unable to create new apk!", string.Format("Unable to move file '{0}' -> '{1}", Path.Combine(this._stagingArea, "Package.apk"), path));
     }
     if (this._useObb && File.Exists(Path.Combine(this._stagingArea, "main.obb")))
     {
         string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
         string str3 = Path.Combine(Path.GetDirectoryName(path), string.Format("{0}.main.obb", fileNameWithoutExtension));
         FileUtil.DeleteFileOrDirectory(str3);
         FileUtil.MoveFileOrDirectory(Path.Combine(this._stagingArea, "main.obb"), str3);
     }
 }
        private void PrepareNonStreamingAssetsForObb(PostProcessorContext context)
        {
            string str = context.Get <string>("StagingArea");

            string[] components = new string[] { str, "assets", "bin" };
            string   path       = Paths.Combine(components);

            FileUtil.CopyDirectoryRecursive(Path.Combine(str, "assets"), Path.Combine(str, "obbassets"));
            string[] textArray2 = new string[] { str, "obbassets", "bin" };
            string   str3       = Paths.Combine(textArray2);

            foreach (string str4 in Directory.GetFiles(str3, "*", SearchOption.AllDirectories))
            {
                if (Regex.IsMatch(str4.Substring(str3.Length + 1).Replace(@"\", "/"), @"^(?:Data/mainData|Data/sharedassets0\.assets(?:\.res[GS]?)?(?:\.split\w+)?|Data/sharedassets0\.resource(?:\.res[GS]?)?(?:\.split\w+)?|Data/level0(?:\.res[GS]?)?(?:\.split\w+)?|Data/globalgamemanagers(?:\.assets)?(?:\.split\w+)?|Data/unity default resources|Data/Resources/unity_builtin_extra|Data/PlayerConnectionConfigFile|Data/Managed/.+\.dll(?:\.mdb)?|Data/.+\.resS)$"))
                {
                    FileUtil.DeleteFileOrDirectory(str4);
                }
            }
            foreach (string str5 in Directory.GetFiles(path, "*", SearchOption.AllDirectories))
            {
                if (!Regex.IsMatch(str5.Substring(path.Length + 1).Replace(@"\", "/"), @"^(?:Data/mainData|Data/sharedassets0\.assets(?:\.res[GS]?)?(?:\.split\w+)?|Data/sharedassets0\.resource(?:\.res[GS]?)?(?:\.split\w+)?|Data/level0(?:\.res[GS]?)?(?:\.split\w+)?|Data/globalgamemanagers(?:\.assets)?(?:\.split\w+)?|Data/unity default resources|Data/Resources/unity_builtin_extra|Data/PlayerConnectionConfigFile|Data/Managed/.+\.dll(?:\.mdb)?|Data/.+\.resS)$"))
                {
                    FileUtil.DeleteFileOrDirectory(str5);
                }
            }
        }
 private void PrepareNativePlugin(PostProcessorContext context, string assetPath, string pluginTargetCPU)
 {
     string[] textArray1;
     string str;
     AndroidTargetDevice device = context.Get<AndroidTargetDevice>("TargetDevice");
     if ((device == AndroidTargetDevice.FAT) || device.ToString().Equals(pluginTargetCPU))
     {
         str = "";
         if (pluginTargetCPU != null)
         {
             if (pluginTargetCPU != "ARMv7")
             {
                 if (pluginTargetCPU == "x86")
                 {
                     str = "x86";
                     goto Label_0088;
                 }
             }
             else
             {
                 str = "armeabi-v7a";
                 goto Label_0088;
             }
         }
         Debug.LogWarning(string.Format("Unknown cpu architecture for .so library ({0})", assetPath));
     }
     return;
 Label_0088:
     textArray1 = new string[] { this._stagingArea, "libs", str };
     string path = Paths.Combine(textArray1);
     Directory.CreateDirectory(path);
     FileUtil.UnityFileCopy(assetPath, Path.Combine(path, Path.GetFileName(assetPath)));
 }
Exemple #26
0
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Checking Android libraries for conflicts");
            }
            string           str       = context.Get <string>("StagingArea");
            AndroidLibraries libraries = context.Get <AndroidLibraries>("AndroidLibraries");

            foreach (string str2 in libraries.GetPackageNames())
            {
                string   path      = Path.Combine(str, "gen");
                char[]   separator = new char[] { '.' };
                string[] strArray2 = str2.Split(separator);
                for (int i = 0; i < strArray2.Length; i++)
                {
 public void Execute(PostProcessorContext context)
 {
     string str = context.Get<string>("StagingArea");
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Preparing and unpacking AAR plugins");
     }
     string str2 = Path.Combine(str, "aar");
     string path = Path.Combine(str, "android-libraries");
     Directory.CreateDirectory(path);
     string[] strArray = AndroidFileLocator.Find(Path.Combine(str2, "*.aar"));
     foreach (string str4 in strArray)
     {
         string fileName = Path.GetFileName(str4);
         string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(str4);
         string str7 = Path.Combine(path, fileNameWithoutExtension);
         if (Directory.Exists(str7))
         {
             CancelPostProcess.AbortBuild("Build failure", "Plugin conflict detected for file " + fileName);
         }
         Directory.CreateDirectory(str7);
         TasksCommon.Exec(AndroidJavaTools.jarPath, "xf \"" + str4 + "\"", str7, "Error unpacking file " + fileName, 0);
         string str8 = Path.Combine(str7, "libs");
         Directory.CreateDirectory(str8);
         FileUtil.MoveFileOrDirectory(Path.Combine(str7, "classes.jar"), Path.Combine(str8, "classes.jar"));
         string str9 = Path.Combine(str7, "jni");
         if (Directory.Exists(str9))
         {
             string str10 = Path.Combine(str7, "libs");
             foreach (string str11 in Directory.GetDirectories(str9, "*"))
             {
                 string to = Path.Combine(str10, FileUtil.RemovePathPrefix(str11, str9));
                 FileUtil.MoveFileOrDirectory(str11, to);
             }
         }
         string str13 = Path.Combine(str7, "src");
         if (!Directory.Exists(str13))
         {
             Directory.CreateDirectory(str13);
         }
         if (!File.Exists(Path.Combine(str7, AndroidLibraries.ProjectPropertiesFileName)))
         {
             int num3 = context.Get<int>("TargetSDKVersion");
             File.WriteAllText(Path.Combine(str7, AndroidLibraries.ProjectPropertiesFileName), string.Format("android.library=true\n\ntarget=android-{0}", num3));
         }
     }
 }
Exemple #28
0
 public void Execute(PostProcessorContext context)
 {
     if (!context.Get <bool>("UseFastzip"))
     {
         this._stagingArea = context.Get <string>("StagingArea");
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Building target package from assets archive and pre-built binaries");
         }
         this.BuildApk(context);
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Optimizing target package alignment");
         }
         this.AlignPackage(context);
     }
 }
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Copying streaming assets");
            }
            bool   flag = context.Get <bool>("UseObb");
            string str  = context.Get <string>("StagingArea");

            string[] components = new string[] { str, "assets", "bin" };
            string   str2       = Paths.Combine(components);

            string[] textArray2 = new string[] { str2, "Data" };
            string   path       = Paths.Combine(textArray2);

            string[] textArray3 = new string[] { str, "raw", "bin", "Data" };
            string   str4       = Paths.Combine(textArray3);

            string[] textArray4 = new string[] { str, "rawobb", "bin", "Data" };
            string   str5       = Paths.Combine(textArray4);
            string   strB       = ".resS";

            string[] fileSystemEntries = Directory.GetFileSystemEntries(path);
            foreach (string str7 in fileSystemEntries)
            {
                if (string.Compare(Path.GetExtension(str7), strB, true) == 0)
                {
                    string str8     = str4;
                    string fileName = Path.GetFileName(str7);
                    if ((flag && (string.Compare(fileName, "level0.resS", true) != 0)) && (string.Compare(fileName, "sharedassets0.assets.resS", true) != 0))
                    {
                        str8 = str5;
                    }
                    if (!Directory.Exists(str8))
                    {
                        Directory.CreateDirectory(str8);
                    }
                    string destFileName = Path.Combine(str8, fileName);
                    File.Move(str7, destFileName);
                }
            }
            if (Directory.Exists("Assets/StreamingAssets"))
            {
                FileUtil.CopyDirectoryRecursiveForPostprocess("Assets/StreamingAssets", Path.Combine(str, !flag ? "raw" : "rawobb"), true);
            }
        }
 public void Execute(PostProcessorContext context)
 {
     this._stagingArea = context.Get<string>("StagingArea");
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Updating resources with player settings");
     }
     this.ReplaceIconResources();
     if (!context.Get<bool>("ExportAndroidProject"))
     {
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Repackaging and recompiling resources");
         }
         this.CompileResources(context);
     }
 }
Exemple #31
0
 public void Execute(PostProcessorContext context)
 {
     if (!context.Get<bool>("UseFastzip"))
     {
         this._stagingArea = context.Get<string>("StagingArea");
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Building target package from assets archive and pre-built binaries");
         }
         this.BuildApk(context);
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Optimizing target package alignment");
         }
         this.AlignPackage(context);
     }
 }
        private void Move(PostProcessorContext context)
        {
            string str  = context.Get <string>("StagingArea");
            bool   flag = context.Get <bool>("UseObb");

            FileUtil.MoveFileOrDirectory(Path.Combine(str, "Package.apk"), this._installPath);
            if (!File.Exists(this._installPath))
            {
                CancelPostProcess.AbortBuild("Unable to create new apk!", $"Unable to move file '{Path.Combine(str, "Package.apk")}' -> '{this._installPath}", null);
            }
            if (flag && File.Exists(Path.Combine(str, "main.obb")))
            {
                string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(this._installPath);
                string path = Path.Combine(this._installDirectory, $"{fileNameWithoutExtension}.main.obb");
                FileUtil.DeleteFileOrDirectory(path);
                FileUtil.MoveFileOrDirectory(Path.Combine(str, "main.obb"), path);
            }
        }
 public void Execute(PostProcessorContext context)
 {
     if (context.Get <bool>("ExportAndroidProject"))
     {
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Exporting Google Android project");
         }
         int system = context.Get <int>("ProjectType");
         AndroidProjectExport export = AndroidProjectExport.Create(system);
         if (export == null)
         {
             throw new UnityException("Unknown project type: " + system);
         }
         string targetPath = context.Get <string>("InstallPath");
         export.Export(context, targetPath);
     }
 }
Exemple #34
0
        private void BuildApk(PostProcessorContext context)
        {
            bool             flag      = context.Get <bool>("DevelopmentPlayer");
            AndroidLibraries libraries = context.Get <AndroidLibraries>("AndroidLibraries");
            bool             flag2     = PlayerSettings.Android.keyaliasName.Length != 0;
            string           str       = Path.Combine(Environment.CurrentDirectory, this._stagingArea);

            string[] first = new string[] { "apk", $"{str}/Package_unaligned.apk", "-z", $"{str}/assets.ap_", "-z", $"{str}/bin/resources.ap_", "-nf", $"{str}/libs", "-f", $"{str}/bin/classes.dex", "-v" };
            foreach (string str2 in libraries.GetLibraryDirectories())
            {
                string[] second = new string[] { "-nf", str2 };
                first = first.Concat <string>(second).ToArray <string>();
            }
            foreach (string str3 in libraries.GetAssetsDirectories())
            {
                string[] textArray3 = new string[] { "-A", str3 };
                first = first.Concat <string>(textArray3).ToArray <string>();
            }
            if (flag2)
            {
                string   str4       = !Path.IsPathRooted(PlayerSettings.Android.keystoreName) ? Path.Combine(Directory.GetCurrentDirectory(), PlayerSettings.Android.keystoreName) : PlayerSettings.Android.keystoreName;
                string[] textArray4 = new string[] { "-k", str4, "-kp", PlayerSettings.Android.keystorePass, "-kk", PlayerSettings.Android.keyaliasName, "-kkp", PlayerSettings.Android.keyaliasPass };
                first = first.Concat <string>(textArray4).ToArray <string>();
            }
            if (flag || Unsupported.IsDeveloperBuild())
            {
                string[] textArray5 = new string[] { "-d" };
                first = first.Concat <string>(textArray5).ToArray <string>();
            }
            if (File.Exists(Path.Combine(this._stagingArea, "raw.ap_")))
            {
                string[] textArray6 = new string[] { "-z", $"{str}/raw.ap_" };
                first = first.Concat <string>(textArray6).ToArray <string>();
            }
            string   message  = TasksCommon.SDKTool(context, first, this._stagingArea, "Failed to build apk.");
            string   fileName = Path.Combine(this._stagingArea, "Package_unaligned.apk");
            FileInfo info     = new FileInfo(fileName);

            if (!File.Exists(fileName) || (info.Length == 0L))
            {
                Debug.LogError(message);
                CancelPostProcess.AbortBuildPointToConsole("APK Builder Failed!", "Failed to build APK package.");
            }
        }
Exemple #35
0
        private void CompileResources(PostProcessorContext context)
        {
            AndroidLibraries libraries = context.Get <AndroidLibraries>("AndroidLibraries");
            string           str       = context.Get <string>("AndroidJarPath");
            AndroidSDKTools  tools     = context.Get <AndroidSDKTools>("SDKTools");
            string           str2      = "gen";
            string           fullName  = Directory.CreateDirectory(Path.Combine(this._stagingArea, str2)).FullName;
            string           args      = $"package --auto-add-overlay -v -f -m -J " { str2 } " -M " { "AndroidManifest.xml" } " -S " { "res" } " -I " { str } " -F {" bin / resources.ap_ "}";

            if (libraries.Count > 0)
            {
                args = args + $" --extra-packages {string.Join(":", libraries.GetPackageNames())}";
                foreach (string str5 in libraries.GetResourceDirectories())
                {
                    args = args + $" -S " { str5 } "";
                }
            }
            string errorMsg = "Failed to re-package resources.";
            string str7     = TasksCommon.Exec(tools.AAPT, args, this._stagingArea, errorMsg, 3);

            if (!str7.Contains("Done!") || !File.Exists(Path.Combine(this._stagingArea, "bin/resources.ap_")))
            {
                Debug.LogError("Failed to re-package resources with the following parameters:\n" + args + "\n" + str7);
                CancelPostProcess.AbortBuildPointToConsole("Resource re-package failed!", errorMsg);
            }
            if (libraries.Count > 0)
            {
                List <string> list = new List <string>();
                foreach (string str8 in Directory.GetFiles(fullName, "*.java", SearchOption.AllDirectories))
                {
                    list.Add(str8.Substring(fullName.Length + 1));
                }
                string str9  = Directory.CreateDirectory(Path.Combine(this._stagingArea, "bin/classes")).FullName;
                string str10 = $"-bootclasspath " { str } " -d " { str9 } " -source 1.6 -target 1.6 -encoding UTF-8 " { string.Join("\" \"", list.ToArray()) } "";
                string str11 = "Failed to recompile android resource files.";
                string str12 = TasksCommon.Exec(AndroidJavaTools.javacPath, str10, fullName, str11, 0);
                if (str12.Trim().Length > 0)
                {
                    Debug.LogError("Failed to compile resources with the following parameters:\n" + str10 + "\n" + str12);
                    CancelPostProcess.AbortBuildPointToConsole("Resource compilation failed!", str11);
                }
            }
        }
 private void GenerateAndroidLibraryWithResources(PostProcessorContext context, string sourceDir, string targetDir)
 {
     int num = context.Get<int>("TargetSDKVersion");
     Directory.CreateDirectory(targetDir);
     string path = Path.Combine(targetDir, "res");
     Directory.CreateDirectory(path);
     File.WriteAllText(Path.Combine(targetDir, AndroidLibraries.ProjectPropertiesFileName), string.Format("android.library=true\n\ntarget=android-{0}", num));
     File.WriteAllText(Path.Combine(targetDir, "AndroidManifest.xml"), string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"{0}\"\nandroid:versionCode=\"1\" android:versionName=\"1.0\"></manifest>", PlayerSettings.bundleIdentifier));
     FileUtil.CopyDirectoryRecursiveForPostprocess(sourceDir, path, true);
 }
Exemple #37
0
 private void BuildApk(PostProcessorContext context)
 {
     bool flag = context.Get<bool>("DevelopmentPlayer");
     AndroidLibraries libraries = context.Get<AndroidLibraries>("AndroidLibraries");
     bool flag2 = PlayerSettings.Android.keyaliasName.Length != 0;
     string str = Path.Combine(Environment.CurrentDirectory, this._stagingArea);
     string[] first = new string[] { "apk", string.Format("{0}/Package_unaligned.apk", str), "-z", string.Format("{0}/assets.ap_", str), "-z", string.Format("{0}/bin/resources.ap_", str), "-nf", string.Format("{0}/libs", str), "-f", string.Format("{0}/bin/classes.dex", str), "-v" };
     foreach (string str2 in libraries.GetLibraryDirectories())
     {
         string[] second = new string[] { "-nf", str2 };
         first = Enumerable.ToArray<string>(Enumerable.Concat<string>(first, second));
     }
     foreach (string str3 in libraries.GetAssetsDirectories())
     {
         string[] textArray3 = new string[] { "-A", str3 };
         first = Enumerable.ToArray<string>(Enumerable.Concat<string>(first, textArray3));
     }
     if (flag2)
     {
         string str4 = !Path.IsPathRooted(PlayerSettings.Android.keystoreName) ? Path.Combine(Directory.GetCurrentDirectory(), PlayerSettings.Android.keystoreName) : PlayerSettings.Android.keystoreName;
         string[] textArray4 = new string[] { "-k", str4, "-kp", PlayerSettings.Android.keystorePass, "-kk", PlayerSettings.Android.keyaliasName, "-kkp", PlayerSettings.Android.keyaliasPass };
         first = Enumerable.ToArray<string>(Enumerable.Concat<string>(first, textArray4));
     }
     if (flag || Unsupported.IsDeveloperBuild())
     {
         string[] textArray5 = new string[] { "-d" };
         first = Enumerable.ToArray<string>(Enumerable.Concat<string>(first, textArray5));
     }
     if (File.Exists(Path.Combine(this._stagingArea, "raw.ap_")))
     {
         string[] textArray6 = new string[] { "-z", string.Format("{0}/raw.ap_", str) };
         first = Enumerable.ToArray<string>(Enumerable.Concat<string>(first, textArray6));
     }
     string message = TasksCommon.SDKTool(context, first, this._stagingArea, "Failed to build apk.");
     string fileName = Path.Combine(this._stagingArea, "Package_unaligned.apk");
     FileInfo info = new FileInfo(fileName);
     if (!File.Exists(fileName) || (info.Length == 0L))
     {
         Debug.LogError(message);
         CancelPostProcess.AbortBuildPointToConsole("APK Builder Failed!", "Failed to build APK package.");
     }
 }
 public void Execute(PostProcessorContext context)
 {
     this._installPath      = context.Get <string>("InstallPath");
     this._installDirectory = Path.GetDirectoryName(this._installPath);
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Moving final Android package");
     }
     this.Clean();
     this.Move(context);
 }
 public void Execute(PostProcessorContext context)
 {
     if (context.Get <bool>("UseObb"))
     {
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Preparing expansion assets");
         }
         this.PrepareNonStreamingAssetsForObb(context);
     }
 }
Exemple #40
0
        public void Execute(PostProcessorContext context)
        {
            this._stagingArea = context.Get <string>("StagingArea");
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Updating resources with player settings");
            }
            this.ReplaceIconResources();
            bool flag  = context.Get <bool>("ExportAndroidProject");
            bool flag2 = context.Get <int>("ProjectType") == 1;

            if (!flag && !flag2)
            {
                if (this.OnProgress != null)
                {
                    this.OnProgress(this, "Repackaging and recompiling resources");
                }
                this.CompileResources(context);
            }
        }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Adding Android libraries");
     }
     string str = context.Get<string>("TargetLibrariesFolder");
     AndroidLibraries libraries = new AndroidLibraries();
     libraries.FindAndAddLibraryProjects(Path.Combine(str, "*"));
     context.Set<AndroidLibraries>("AndroidLibraries", libraries);
 }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Copying streaming assets");
     }
     bool flag = context.Get<bool>("UseObb");
     string str = context.Get<string>("StagingArea");
     string[] components = new string[] { str, "assets", "bin" };
     string str2 = Paths.Combine(components);
     string[] textArray2 = new string[] { str2, "Data" };
     string path = Paths.Combine(textArray2);
     string[] textArray3 = new string[] { str, "raw", "bin", "Data" };
     string str4 = Paths.Combine(textArray3);
     string[] textArray4 = new string[] { str, "rawobb", "bin", "Data" };
     string str5 = Paths.Combine(textArray4);
     string strB = ".resS";
     string[] fileSystemEntries = Directory.GetFileSystemEntries(path);
     foreach (string str7 in fileSystemEntries)
     {
         if (string.Compare(Path.GetExtension(str7), strB, true) == 0)
         {
             string str8 = str4;
             string fileName = Path.GetFileName(str7);
             if ((flag && (string.Compare(fileName, "level0.resS", true) != 0)) && (string.Compare(fileName, "sharedassets0.assets.resS", true) != 0))
             {
                 str8 = str5;
             }
             if (!Directory.Exists(str8))
             {
                 Directory.CreateDirectory(str8);
             }
             string destFileName = Path.Combine(str8, fileName);
             File.Move(str7, destFileName);
         }
     }
     if (Directory.Exists("Assets/StreamingAssets"))
     {
         FileUtil.CopyDirectoryRecursiveForPostprocess("Assets/StreamingAssets", Path.Combine(str, !flag ? "raw" : "rawobb"), true);
     }
 }
 private void CompileResources(PostProcessorContext context)
 {
     AndroidLibraries libraries = context.Get<AndroidLibraries>("AndroidLibraries");
     string str = context.Get<string>("AndroidJarPath");
     AndroidSDKTools tools = context.Get<AndroidSDKTools>("SDKTools");
     string str2 = "gen";
     string fullName = Directory.CreateDirectory(Path.Combine(this._stagingArea, str2)).FullName;
     string args = string.Format("package --auto-add-overlay -v -f -m -J \"{0}\" -M \"{1}\" -S \"{2}\" -I \"{3}\" -F {4}", new object[] { str2, "AndroidManifest.xml", "res", str, "bin/resources.ap_" });
     if (libraries.Count > 0)
     {
         args = args + string.Format(" --extra-packages {0}", string.Join(":", libraries.GetPackageNames()));
         foreach (string str5 in libraries.GetResourceDirectories())
         {
             args = args + string.Format(" -S \"{0}\"", str5);
         }
     }
     string errorMsg = "Failed to re-package resources.";
     string str7 = TasksCommon.Exec(tools.AAPT, args, this._stagingArea, errorMsg, 3);
     if (!str7.Contains("Done!") || !File.Exists(Path.Combine(this._stagingArea, "bin/resources.ap_")))
     {
         Debug.LogError("Failed to re-package resources with the following parameters:\n" + args + "\n" + str7);
         CancelPostProcess.AbortBuildPointToConsole("Resource re-package failed!", errorMsg);
     }
     if (libraries.Count > 0)
     {
         List<string> list = new List<string>();
         foreach (string str8 in Directory.GetFiles(fullName, "*.java", SearchOption.AllDirectories))
         {
             list.Add(str8.Substring(fullName.Length + 1));
         }
         string str9 = Directory.CreateDirectory(Path.Combine(this._stagingArea, "bin/classes")).FullName;
         string str10 = string.Format("-bootclasspath \"{0}\" -d \"{1}\" -source 1.6 -target 1.6 -encoding UTF-8 \"{2}\"", str, str9, string.Join("\" \"", list.ToArray()));
         string str11 = "Failed to recompile android resource files.";
         string str12 = TasksCommon.Exec(AndroidJavaTools.javacPath, str10, fullName, str11, 0);
         if (str12.Trim().Length > 0)
         {
             Debug.LogError("Failed to compile resources with the following parameters:\n" + str10 + "\n" + str12);
             CancelPostProcess.AbortBuildPointToConsole("Resource compilation failed!", str11);
         }
     }
 }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Patching settings file");
     }
     this._stagingArea = context.Get<string>("StagingArea");
     bool flag = context.Get<bool>("UseObb");
     string str = context.Get<string>("AndroidPluginsPath");
     if (Directory.Exists(Path.Combine(str, "assets")))
     {
         FileUtil.CopyDirectoryRecursiveForPostprocess(Path.Combine(str, "assets"), Path.Combine(this._stagingArea, "assets"), true);
     }
     this.PatchStringsXml();
     int num = !PlayerSettings.advancedLicense ? 0 : ((int) PlayerSettings.Android.splashScreenScale);
     AndroidXmlDocument document = new AndroidXmlDocument(Path.Combine(this._stagingArea, "assets/bin/Data/settings.xml"));
     document.PatchStringRes("integer", "splash_mode", num.ToString());
     document.PatchStringRes("bool", "useObb", flag.ToString());
     context.Set<AndroidXmlDocument>("SettingsXml", document);
     document.Save();
 }
Exemple #45
0
 public void Execute(PostProcessorContext context)
 {
     this._stagingArea = context.Get<string>("StagingArea");
     this._androidLibraries = context.Get<AndroidLibraries>("AndroidLibraries");
     bool flag = context.Get<bool>("HasJarPlugins");
     bool flag2 = context.Get<bool>("ExportAndroidProject");
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Converting Java classes to dex-format");
     }
     if (!flag2 && (flag || (this._androidLibraries.Count > 0)))
     {
         this.BuildDex(context);
     }
     else
     {
         string[] components = new string[] { TasksCommon.GetClassDirectory(context), "classes.dex" };
         string[] textArray2 = new string[] { this._stagingArea, "bin", "classes.dex" };
         FileUtil.CopyFileOrDirectory(Paths.Combine(components), Paths.Combine(textArray2));
     }
 }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Starting Android build");
     }
     this.EnsureUnityLibrariesAreAvailable(context);
     if (!context.Get <bool>("ExportAndroidProject") && !this.ArePasswordsProvided())
     {
         CancelPostProcess.AbortBuild("Can not sign application", "Unable to sign application; please provide passwords!", null);
     }
 }
Exemple #47
0
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Adding Android libraries");
            }
            string           str       = context.Get <string>("TargetLibrariesFolder");
            AndroidLibraries libraries = new AndroidLibraries();

            libraries.FindAndAddLibraryProjects(Path.Combine(str, "*"));
            context.Set <AndroidLibraries>("AndroidLibraries", libraries);
        }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Starting Android build");
     }
     this.EnsureUnityLibrariesAreAvailable(context);
     if (!context.Get<bool>("ExportAndroidProject") && !this.ArePasswordsProvided())
     {
         CancelPostProcess.AbortBuild("Can not sign application", "Unable to sign application; please provide passwords!");
     }
 }
Exemple #49
0
        public void Execute(PostProcessorContext context)
        {
            this._stagingArea      = context.Get <string>("StagingArea");
            this._androidLibraries = context.Get <AndroidLibraries>("AndroidLibraries");
            bool flag  = context.Get <bool>("HasJarPlugins");
            bool flag2 = context.Get <bool>("ExportAndroidProject");

            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Converting Java classes to dex-format");
            }
            if (!flag2 && (flag || (this._androidLibraries.Count > 0)))
            {
                this.BuildDex(context);
            }
            else
            {
                string[] components = new string[] { TasksCommon.GetClassDirectory(context), "classes.dex" };
                string[] textArray2 = new string[] { this._stagingArea, "bin", "classes.dex" };
                FileUtil.CopyFileOrDirectory(Paths.Combine(components), Paths.Combine(textArray2));
            }
        }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Copying unity resources");
     }
     string str = context.Get<string>("PlayerPackage");
     string str2 = context.Get<string>("StagingArea");
     string from = context.Get<string>("StagingAreaData");
     string[] components = new string[] { str, "Data", "unity default resources" };
     string[] textArray2 = new string[] { from, "unity default resources" };
     FileUtil.CopyFileOrDirectory(Paths.Combine(components), Paths.Combine(textArray2));
     string[] textArray3 = new string[] { str2, "assets", "bin" };
     string path = Paths.Combine(textArray3);
     Directory.CreateDirectory(path);
     FileUtil.MoveFileOrDirectory(from, Path.Combine(path, "Data"));
     if (!context.Get<bool>("DevelopmentPlayer"))
     {
         string[] textArray4 = new string[] { path, "Data", "Managed" };
         this.CleanupMdbFiles(Paths.Combine(textArray4));
     }
 }
Exemple #51
0
 private void AlignPackage(PostProcessorContext context)
 {
     AndroidSDKTools tools = context.Get<AndroidSDKTools>("SDKTools");
     string errorMsg = "Failed to align APK package.";
     string str2 = Path.Combine(Environment.CurrentDirectory, this._stagingArea);
     string args = string.Format("4 \"{0}/Package_unaligned.apk\" \"{0}/Package.apk\"", str2);
     string message = TasksCommon.Exec(tools.ZIPALIGN, args, this._stagingArea, errorMsg, 0);
     if ((message.Contains("zipalign") || message.Contains("Warning")) || !File.Exists(Path.Combine(str2, "Package.apk")))
     {
         Debug.LogError(message);
         CancelPostProcess.AbortBuildPointToConsole("APK Aligning Failed!", errorMsg);
     }
 }
 public void Execute(PostProcessorContext context)
 {
     if (context.Get<bool>("AutoRunPlayer"))
     {
         AndroidDevice device = null;
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Getting list of attached devices");
         }
         device = this.FindDevice(context);
         context.Set<AndroidDevice>("AndroidDevice", device);
     }
 }
 public void Execute(PostProcessorContext context)
 {
     if (context.Get <bool>("AutoRunPlayer"))
     {
         AndroidDevice device = null;
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Getting list of attached devices");
         }
         device = this.FindDevice(context);
         context.Set <AndroidDevice>("AndroidDevice", device);
     }
 }
Exemple #54
0
        private void GenerateAndroidLibraryWithResources(PostProcessorContext context, string sourceDir, string targetDir)
        {
            int num = context.Get<int>("TargetSDKVersion");
            Directory.CreateDirectory(targetDir);
            string path = Path.Combine(targetDir, "res");
            Directory.CreateDirectory(path);
            File.WriteAllText(Path.Combine(targetDir, AndroidLibraries.ProjectPropertiesFileName), $"android.library=true

target=android-{num}");
            File.WriteAllText(Path.Combine(targetDir, "AndroidManifest.xml"), $"<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="{PlayerSettings.bundleIdentifier}.resources"
android:versionCode="1" android:versionName="1.0"></manifest>");
            FileUtil.CopyDirectoryRecursiveForPostprocess(sourceDir, path, true);
        }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Splitting large asset files");
     }
     string str = context.Get<string>("StagingArea");
     string[] components = new string[] { str, "assets", "bin", "Data" };
     this.SplitFiles(Paths.Combine(components), "*.assets", 0x100000);
     string[] textArray2 = new string[] { str, "assets", "bin", "Data" };
     this.SplitFiles(Paths.Combine(textArray2), "*.resource", 0x100000);
     string[] textArray3 = new string[] { str, "assets", "bin", "Data" };
     this.SplitFiles(Paths.Combine(textArray3), "level*", 0x100000);
 }
Exemple #56
0
        private void AlignPackage(PostProcessorContext context)
        {
            AndroidSDKTools tools    = context.Get <AndroidSDKTools>("SDKTools");
            string          errorMsg = "Failed to align APK package.";
            string          str2     = Path.Combine(Environment.CurrentDirectory, this._stagingArea);
            string          args     = string.Format("4 \"{0}/Package_unaligned.apk\" \"{0}/Package.apk\"", str2);
            string          message  = TasksCommon.Exec(tools.ZIPALIGN, args, this._stagingArea, errorMsg, 0);

            if ((message.Contains("zipalign") || message.Contains("Warning")) || !File.Exists(Path.Combine(str2, "Package.apk")))
            {
                Debug.LogError(message);
                CancelPostProcess.AbortBuildPointToConsole("APK Aligning Failed!", errorMsg);
            }
        }
 public void Execute(PostProcessorContext context)
 {
     if (context.Get<bool>("ExportAndroidProject"))
     {
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Exporting Google Android project");
         }
         this._playerPackage = context.Get<string>("PlayerPackage");
         string stagingArea = context.Get<string>("StagingArea");
         AndroidLibraries androidLibraries = context.Get<AndroidLibraries>("AndroidLibraries");
         string targetPath = context.Get<string>("InstallPath");
         string packageName = context.Get<string>("PackageName");
         bool useObb = context.Get<bool>("UseObb");
         int platformApiLevel = context.Get<int>("PlatformApiLevel");
         string googleBuildTools = context.Get<AndroidSDKTools>("SDKTools").BuildToolsVersion(null);
         int num2 = context.Get<int>("ProjectType");
         switch (num2)
         {
             case 2:
             {
                 string[] components = new string[] { this._playerPackage, "Source" };
                 string[] textArray2 = new string[] { TasksCommon.GetClassDirectory(context), "classes.jar" };
                 AndroidProjectExport.ExportADT(Paths.Combine(components), Paths.Combine(textArray2), BuildPipeline.GetBuildToolsDirectory(BuildTarget.Android), stagingArea, androidLibraries, targetPath, packageName, PlayerSettings.productName, platformApiLevel, useObb);
                 return;
             }
             case 1:
             {
                 string[] textArray3 = new string[] { this._playerPackage, "Source" };
                 string[] textArray4 = new string[] { TasksCommon.GetClassDirectory(context), "classes.jar" };
                 AndroidProjectExport.ExportGradle(Paths.Combine(textArray3), Paths.Combine(textArray4), BuildPipeline.GetBuildToolsDirectory(BuildTarget.Android), stagingArea, androidLibraries, targetPath, packageName, PlayerSettings.productName, platformApiLevel, googleBuildTools, useObb);
                 return;
             }
         }
         throw new UnityException("Unknown project type: " + num2);
     }
 }
 private void EnsureUnityLibrariesAreAvailable(PostProcessorContext context)
 {
     AndroidTargetDevice device = context.Get<AndroidTargetDevice>("TargetDevice");
     switch (device)
     {
         case AndroidTargetDevice.FAT:
         case AndroidTargetDevice.ARMv7:
             this.CheckUnityLibraryForArchitecture(context, "armeabi-v7a");
             break;
     }
     if ((device == AndroidTargetDevice.FAT) || (device == AndroidTargetDevice.x86))
     {
         this.CheckUnityLibraryForArchitecture(context, "x86");
     }
 }
 private void AAPTPack(PostProcessorContext context, string apkName, string directory, bool compress)
 {
     AndroidSDKTools tools = context.Get<AndroidSDKTools>("SDKTools");
     string str = "";
     if (!compress)
     {
         str = " -0 \"\"";
     }
     string str2 = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~";
     string args = string.Format("package -v -f -F {0} -A {1}{2} --ignore-assets \"{3}\"", new object[] { apkName, directory, str, str2 });
     string str4 = TasksCommon.Exec(tools.AAPT, args, this._stagingArea, "Android Asset Packaging Tool failed.", 3);
     if (!str4.Contains("Found 0 custom asset files") && (!str4.Contains("Done!") || !File.Exists(Path.Combine(this._stagingArea, apkName))))
     {
         Debug.LogError(string.Format("Android Asset Packaging Tool failed: {0} {1} \n {2}", tools.AAPT, args, str4));
         CancelPostProcess.AbortBuildPointToConsole("AAPT Failed!", "Android Asset Packaging Tool failed.");
     }
 }
 private void PrepareNativeUnityLibs(PostProcessorContext context, string abi)
 {
     string pluginSourceFolder = context.Get<string>("AndroidPluginsPath");
     string[] components = new string[] { this._stagingArea, "libs", abi };
     string to = Paths.Combine(components);
     string[] textArray2 = new string[] { TasksCommon.GetVariationsDirectory(context), "Libs" };
     string str3 = Paths.Combine(textArray2);
     string[] textArray3 = new string[] { this._stagingArea, "libs" };
     Directory.CreateDirectory(Paths.Combine(textArray3));
     string[] textArray4 = new string[] { str3, abi };
     FileUtil.CopyFileOrDirectory(Paths.Combine(textArray4), to);
     string[] textArray5 = new string[] { pluginSourceFolder, "libs", abi };
     string str4 = Paths.Combine(textArray5);
     string[] textArray6 = new string[] { to, "gdbserver" };
     if (!File.Exists(Paths.Combine(textArray6)) && !PostprocessBuildPlayer.InstallPluginsByExtension(pluginSourceFolder, "gdbserver", string.Empty, to, false))
     {
         PostprocessBuildPlayer.InstallPluginsByExtension(str4, "gdbserver", string.Empty, to, false);
     }
 }