//开始打包 private void packing() { int progress = 0; progressBar1.Value = 0; label5.Text = progress++ + " / " + mChooseChannelTable.Count; ApkUtils apkUtils = new ApkUtils(logListBox); //1. 解包 apkUtils.unApk(apkPath); foreach (String channelName in mChooseChannelTable.Keys) { progressBar1.Value = 0; progressBar1.Value++; String channelId = (String)mChooseChannelTable[channelName]; label5.Text = progress++ + " / " + mChooseChannelTable.Count; //2. 修改包名 if (textBox2.Text.Length != 0) { //logListBox.AppendText("修改包名:" + "\r\n"); modifiPackageName(); } progressBar1.Value++; //3. 修改渠道号 //logListBox.AppendText("修改渠道号:" + "\r\n"); modifiChannelId(channelId); progressBar1.Value++; //4. 合包 apkUtils.joinApk(apkName); progressBar1.Value++; //5. 签名 apkUtils.signApk(apkName); progressBar1.Value++; //6. 优化 apkUtils.alignApk(apkName, "package" + "\\" + apkName + "_" + channelId); progressBar1.Value++; } //7. 删除临时文件 apkUtils.deleteFile(apkName); timer1.Enabled = false; MessageBox.Show("打包完成,打包时间:" + label6.Text, "提示", MessageBoxButtons.OK); logListBox.AppendText("打包完成"); packingBtn.Enabled = true; }
//开始打包 private void doPackingAPK() { ApkUtils apkUtils = new ApkUtils(logList); //11.删除临时文件 //apkUtils.deleteFile(apkName + " temp out"); //1.解包命令 apkUtils.unApk(apkPath); //2.复制assets命令 apkUtils.copyFile("sdk_res\\" + channel + "\\assets", apkName + "\\assets"); apkUtils.copyFile("temp", apkName + "\\assets"); //3.修改Manifest文件 updateManifest(); //4.复制res命令 apkUtils.copyFile("sdk_res\\" + channel + "\\res", apkName + "\\res"); //4.复制多渠道jar包命令 //apkUtils.copyFile("sdk_res\\*.jar" + channel + "\\res", "sdk_res\\" + channel + "\\libs"); //5.jar to dex apkUtils.jar2dex("sdk_res\\*.jar"); //6.dex to smali apkUtils.dex2smali(); //5.jar to dex apkUtils.jar2dex("sdk_res\\" + channel + "\\libs\\*.jar"); //6.dex to smali apkUtils.dex2smali(); //7.复制smali文件 apkUtils.copyFile("out", apkName + "\\smali"); //8.合包 apkUtils.joinApk(apkName); //9.签名 apkUtils.signApk(apkName); //10.优化 apkUtils.alignApk(apkName, "package\\" + apkName + "_" + channel); //11.删除临时文件 //apkUtils.deleteFile(apkName + " temp out classes.dex"); //MessageBox.Show("打包完成!", "提示", MessageBoxButtons.OK); }
public ApkToolsForm() { InitializeComponent(); apkUtils = new ApkUtils(textBox3); }