Skip to content

Commit

Permalink
Fixed zipalign issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AndnixSH committed Sep 30, 2023
1 parent 07e4026 commit ec6fd42
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
31 changes: 17 additions & 14 deletions APKToolGUI/Forms/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@ internal async Task<int> Build(string inputFolder)
await Task.Factory.StartNew(() =>
{
string outputFile = inputFolder + " compiled.apk";
string outputUnsignedApk = inputFolder + " unsigned.apk";
if (Settings.Default.Build_SignAfterBuild)
outputFile = inputFolder + " signed.apk";
if (Settings.Default.Build_UseOutputAppPath && !IgnoreOutputDirContextMenu)
Expand Down Expand Up @@ -985,6 +986,22 @@ await Task.Factory.StartNew(() =>
{
ToLog(ApktoolEventType.None, String.Format(Language.CompilingSuccessfullyCompleted, outputFile));

if (Settings.Default.Build_CreateUnsignedApk)
{
ToStatus(Language.CreateUnsignedApk, Resources.waiting);
ToLog(ApktoolEventType.Infomation, "=====[ " + Language.CreateUnsignedApk + " ]=====");

if (Directory.Exists(Path.Combine(inputFolder, "original", "META-INF")))
{
string unsignedApkPath = Path.Combine(Path.GetDirectoryName(outputCompiledApkFile), Path.GetFileName(outputUnsignedApk));
ZipUtils.UpdateDirectory(outputFile, Path.Combine(inputFolder, "original", "META-INF"), "META-INF");
ToLog(ApktoolEventType.Infomation, String.Format(Language.CopyFileTo, outputFile, unsignedApkPath));
File.Copy(outputFile, unsignedApkPath, true);
}
else
ToLog(ApktoolEventType.Warning, Language.MetainfNotExist);
}

if (Settings.Default.Build_ZipalignAfterBuild)
{
ToStatus(Language.Aligning, Resources.waiting);
Expand All @@ -994,20 +1011,6 @@ await Task.Factory.StartNew(() =>
if (zipalign.Align(outputFile, outputFile) == 0)
{
ToLog(ApktoolEventType.None, Language.Done);
if (Settings.Default.Build_CreateUnsignedApk)
{
ToStatus(Language.CreateUnsignedApk, Resources.waiting);
ToLog(ApktoolEventType.Infomation, "=====[ " + Language.CreateUnsignedApk + " ]=====");

if (Directory.Exists(Path.Combine(inputFolder, "original", "META-INF")))
{
ZipUtils.UpdateDirectory(outputFile, Path.Combine(inputFolder, "original", "META-INF"), "META-INF");
File.Copy(outputFile, Path.Combine(Path.GetDirectoryName(outputFile), Path.GetFileName(inputFolder) + " unsigned.apk"), true);
ToLog(ApktoolEventType.None, Language.Done);
}
else
ToLog(ApktoolEventType.Warning, Language.MetainfNotExist);
}
}
else
{
Expand Down
9 changes: 9 additions & 0 deletions APKToolGUI/Languages/Language.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions APKToolGUI/Languages/Language.resx
Original file line number Diff line number Diff line change
Expand Up @@ -534,4 +534,7 @@
<data name="FixApktoolYml" xml:space="preserve">
<value>Fixed apktool.yml</value>
</data>
<data name="CopyFileTo" xml:space="preserve">
<value>Copy file "{0}" to "{1}"</value>
</data>
</root>

0 comments on commit ec6fd42

Please sign in to comment.