Esempio n. 1
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.");
            }
        }
Esempio n. 2
0
        private void CreatePackagesWithFastzip(PostProcessorContext context)
        {
            string             str5;
            string             str6;
            string             str7;
            FileInfo           info;
            string             workingdir = context.Get <string>("StagingArea");
            bool               flag       = context.Get <bool>("UseObb");
            AndroidLibraries   libraries  = context.Get <AndroidLibraries>("AndroidLibraries");
            AndroidXmlDocument document   = context.Get <AndroidXmlDocument>("SettingsXml");
            string             command    = context.Get <string>("FastzipExe");
            string             str3       = "Package.apk";
            string             errorMsg   = "Fastzip failed.";
            string             str8       = " -j --seq -5";

            if (flag)
            {
                if (this.OnProgress != null)
                {
                    this.OnProgress(this, "Using fastzip to build expansion package (OBB)");
                }
                str6 = ("main.obb" + str8 + " obbassets=assets") + " rawobb=assets";
                str5 = TasksCommon.Exec(command, str6, workingdir, errorMsg, 0);
                str7 = Path.Combine(workingdir, "main.obb");
                info = new FileInfo(str7);
                if (!File.Exists(str7) || (info.Length == 0L))
                {
                    Debug.LogError(str5);
                    CancelPostProcess.AbortBuildPointToConsole("OBB Builder Failed!", "Failed to build OBB package.");
                }
                if (info.Length >= 0x80000000L)
                {
                    Debug.LogError(str5);
                    CancelPostProcess.AbortBuildPointToConsole("OBB Builder Failed!", "OBB file too big for Android Market (max 2GB).");
                }
                document.PatchStringRes("bool", TasksCommon.GetMD5HashOfEOCD(str7), true.ToString());
                document.Save();
            }
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Using fastzip to build target package (APK)");
            }
            string str9 = " libs=lib";

            foreach (string str10 in libraries.GetLibraryDirectories())
            {
                str9 = str9 + $" {str10}=libs";
            }
            string str11 = " --apk";

            if (PlayerSettings.Android.keyaliasName.Length != 0)
            {
                string str12 = !Path.IsPathRooted(PlayerSettings.Android.keystoreName) ? Path.Combine(Directory.GetCurrentDirectory(), PlayerSettings.Android.keystoreName) : PlayerSettings.Android.keystoreName;
                str11 = $" -A --sign={str12},{PlayerSettings.Android.keyaliasPass},{PlayerSettings.Android.keyaliasName}";
            }
            string[] textArray1 = new string[] { str3, str8, str11, str9, " bin/classes.dex assets -0 -Z bin/resources.ap_ raw=assets" };
            str6 = string.Concat(textArray1);
            str5 = TasksCommon.Exec(command, str6, workingdir, errorMsg, 0);
            str7 = Path.Combine(workingdir, str3);
            info = new FileInfo(str7);
            if (!File.Exists(str7) || (info.Length == 0L))
            {
                Debug.LogError(str5);
                CancelPostProcess.AbortBuildPointToConsole("Fastzip Failed!", "Failed to build APK package.");
            }
        }