public static void BuildMiInstallPackage(bool fullPackage = true)
    {
        SetLauncherIconSetting(new string[] {
            "Assets/SDKIcon/gfan/ic_launcher144.png",
            "Assets/SDKIcon/gfan/ic_launcher72.png",
            "Assets/SDKIcon/gfan/ic_launcher48.png",
            "Assets/SDKIcon/gfan/ic_launcher48.png",
        });

        string platform = PlatformMi;
        string suffix   = GetBundleIdentifierSplitChar() + platform;

        RecordChannel2Resouces(platform);
        CleanupBundleIdentifier();
        PlayerSettings.applicationIdentifier += suffix;
#if UNITY_ANDROID
        ModifyManifestPackageName(BuildAndroid.ManifestEntryPackageName + suffix);
        if (fullPackage)
        {
            // tzz added for preprocessing for build full apk
            // change AndroidMenifest file and copy the base jar file to right folder
            BuildAndroid.PreProcessToBuildFullApk();
            BuildAndroidPackage(platform);
        }
        else
        {
            BuildAndroid.BuildSplitGame(BuildAndroid.GetCombineApkName(platform));
        }
#elif UNITY_IPHONE
#endif
    }
    public static string BuildGfanInstallPackage(bool fullPackage = true, string subChannel = "")
    {
        SetLauncherIconSetting(new string[] {
#if UNITY_ANDROID
            "Assets/SDKIcon/gfan/ic_launcher144.png",
            "Assets/SDKIcon/gfan/ic_launcher72.png",
            "Assets/SDKIcon/gfan/ic_launcher48.png",
            "Assets/SDKIcon/gfan/ic_launcher48.png",
#elif UNITY_IPHONE
            "Assets/SDKIcon/gfan/ic_launcher57.png",
            "Assets/SDKIcon/gfan/ic_launcher114.png",
            "Assets/SDKIcon/gfan/ic_launcher72.png",
            "Assets/SDKIcon/gfan/ic_launcher144.png",
#endif
        });
        string path = "";

        string platform = PlatformGfan;
        string suffix   = GetBundleIdentifierSplitChar() + platform;

        RecordChannel2Resouces(platform + subChannel);
        CleanupBundleIdentifier();
        // PlayerSettings.bundleIdentifier += suffix;
#if UNITY_ANDROID
        // modify the manifest.xml file
        ModifyManifestPackageName(BuildAndroid.ManifestEntryPackageName);
        if (fullPackage)
        {
            // tzz added for preprocessing for build full apk
            // change AndroidMenifest file and copy the base jar file to right folder
            BuildAndroid.PreProcessToBuildFullApk();
            path = BuildAndroidPackage(platform);
        }
        else
        {
            BuildAndroid.BuildSplitGame(BuildAndroid.GetCombineApkName(platform));
        }
#elif UNITY_IPHONE
        BuildXcodeProject("GfanSDK");
#endif
        return(path);
    }
    static void RecordSubChannel2Resouces(string subChannedId)
    {
        using (FileStream fs = new FileStream("Assets/Resources/SDKSubChannel.txt", FileMode.OpenOrCreate))
        {
            fs.SetLength(0);
            fs.Flush();

            using (StreamWriter writer = new StreamWriter(fs))
            {
                writer.Write(subChannedId);
                writer.Close();
            }
            fs.Close();
        }

        BuildAndroid.ModifyAndroidManifestMeta("WIIPAY_CHANNEL_CODE", subChannedId);
        BuildAndroid.ModifyAndroidManifestMeta("Channel_ID", subChannedId);

        AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
    }
    public static void BuildMultCPsAndroid()
    {
        // tzz added for preprocessing for build full apk
        // change AndroidMenifest file and copy the base jar file to right folder
        BuildAndroid.PreProcessToBuildFullApk();

        int assetIdx = Application.dataPath.IndexOf("/Assets");

        projectPath = Application.dataPath.Substring(0, assetIdx) + "/";

        ReadChannelIdsFile(projectPath + channelFilePath);
        ReadManifestContents();

        for (int i = 0; i < channelIds.Count; i++)
        {
            BuildOneChannelApk(channelIds[i]);
        }

        ResetManifestChannelId();
    }
    static void BuildWPayInstallPackage(string subChannnelID, bool fullPackage = true)
    {
        SetLauncherIconSetting(new string[] {
#if UNITY_ANDROID
            "Assets/SDKIcon/wpay/ic_launcher144.png",
            "Assets/SDKIcon/wpay/ic_launcher72.png",
            "Assets/SDKIcon/wpay/ic_launcher48.png",
            "Assets/SDKIcon/wpay/ic_launcher48.png",
#elif UNITY_IPHONE
            "Assets/SDKIcon/91/ic_launcher57.png",
            "Assets/SDKIcon/91/ic_launcher114.png",
            "Assets/SDKIcon/91/ic_launcher72.png",
            "Assets/SDKIcon/91/ic_launcher144.png",
#endif
        });

        string platform = PlatformWPay;
        string suffix   = GetBundleIdentifierSplitChar() + platform;

        RecordChannel2Resouces(platform);
        RecordSubChannel2Resouces(subChannnelID);
        CleanupBundleIdentifier();
        PlayerSettings.applicationIdentifier += suffix;
#if UNITY_ANDROID
        ModifyManifestPackageName(BuildAndroid.ManifestEntryPackageName + suffix);
        if (fullPackage)
        {
            // tzz added for preprocessing for build full apk
            // change AndroidMenifest file and copy the base jar file to right folder
            BuildAndroid.PreProcessToBuildFullApk();
            BuildAndroidPackage(platform, subChannnelID);
        }
        else
        {
            BuildAndroid.BuildSplitGame(BuildAndroid.GetCombineApkName(platform));
        }
#elif UNITY_IPHONE
        BuildXcodeProject("ND91SDK");
#endif
    }
    static string BuildAndroidPackage(string channelId, string subChannelId = "", string postfix = ".apk")
    {
        BuildAndroid.PreProcessDigitalSignature();
        //@{{ CAUTION!!
        //
        // delete the other SDK alipay_msp.jar to avoid conflict with the one in gfansdk_pay.jar
        //
        string alipayFile;
        string backupAlipay;

        if (channelId.StartsWith(PlatformGfan))
        {
            alipayFile   = Application.dataPath + "/Plugins/Android/libs/alipay_msp.jar";
            backupAlipay = Application.dataPath + "/alipay_msp.jar";
        }
        else
        {
            alipayFile   = Application.dataPath + "/Plugins/Android/libs/gfansdk_pay.jar";
            backupAlipay = Application.dataPath + "/gfansdk_pay.jar";
        }

        if (File.Exists(alipayFile))
        {
            if (File.Exists(backupAlipay))
            {
                File.Delete(backupAlipay);
            }

            File.Move(alipayFile, backupAlipay);
        }
        else
        {
            throw new System.Exception("Failed!! Please Update SVN to restore : " + alipayFile);
        }
        //@}}


        // Prepare all levels
        List <string>            levels = new List <string>();
        EditorBuildSettingsScene scene  = null;

        for (int i = 0; i < EditorBuildSettings.scenes.Length; i++)
        {
            scene = EditorBuildSettings.scenes[i];
            if (scene.enabled)
            {
                levels.Add(scene.path);
            }
        }

        string path = BuildAndroid.GetCombineApkName(channelId, subChannelId, postfix);

        BuildPipeline.BuildPlayer(levels.ToArray(), path, BuildTarget.Android, BuildOptions.None);

        //@{{ CAUTION!!
        //
        // copy back
        //
        if (!File.Exists(alipayFile))
        {
            if (File.Exists(backupAlipay))
            {
                File.Move(backupAlipay, alipayFile);
            }
            else
            {
                throw new System.Exception("Failed!! Please Update SVN to restore : " + alipayFile);
            }
        }
        //@}}

        return(path);
    }
 /// <summary>
 /// Pre-process to build full apk.
 /// change AndroidMenifest file and copy the base jar file to right folder
 /// </summary>
 public static void PreProcessToBuildFullApk()     // tzz added
 // to change the install spliter
 {
     BuildAndroid.ModifyAndroidManifestMeta("install_split", "false");
     File.Copy(Path.Combine(Application.dataPath, "Editor/AndroidBuilder/androidGfanPay.jar"), Path.Combine(Application.dataPath, "Plugins/Android/libs/androidGfanPay.jar"), true);
 }