mirror of
https://github.com/AndnixSH/APKToolGUI.git
synced 2026-05-04 11:02:27 +00:00
fix: correct signing/build option handling and drag-drop stability
Use Sign_UseOutputDir in signing flows instead of Zipalign_UseOutputDir Fix apktool arg composition so -api and -j are both preserved Fix JarProcess JVM arg order and default java executable handling Replace non-functional splitTypes string replacement with Regex.Replace in ApkFixer Remove duplicate private-key click handler registration Fix APK info drag-drop target textbox and guard drag-drop helpers against empty drops Keep DEBUG/RELEASE catch split to avoid CS0168 in Release
This commit is contained in:
@@ -30,8 +30,8 @@ namespace APKToolGUI.ApkTool
|
||||
manifestText = manifestText.Replace("android:manageSpace=\"true\"", "");
|
||||
manifestText = manifestText.Replace("android:localeConfig=\"@xml/locales_config\"", "");
|
||||
manifestText = manifestText.Replace("STAMP_TYPE_DISTRIBUTION_APK", "STAMP_TYPE_STANDALONE_APK");
|
||||
manifestText = manifestText.Replace("android:requiredSplitTypes=\"(.*?)\"", "");
|
||||
manifestText = manifestText.Replace("android:splitTypes=\"(.*?)\"", "");
|
||||
manifestText = Regex.Replace(manifestText, @"\s*android:requiredSplitTypes=""[^""]*""", "");
|
||||
manifestText = Regex.Replace(manifestText, @"\s*android:splitTypes=""[^""]*""", "");
|
||||
|
||||
File.WriteAllText(manifestPath, manifestText);
|
||||
return true;
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace APKToolGUI
|
||||
|
||||
public int Decompile(string inputPath, string outputDir)
|
||||
{
|
||||
string keyNoSrc = null, keyNoRes = null, keyForce = null, keyFramePath = null, keyMatchOriginal = null, keyOutputDir = null, onlyMainClasses = null, noDebugInfo = null, keyKeepBrokenRes = null, apiLevel = null;
|
||||
string keyNoSrc = null, keyNoRes = null, keyForce = null, keyFramePath = null, keyMatchOriginal = null, keyOutputDir = null, onlyMainClasses = null, noDebugInfo = null, keyKeepBrokenRes = null, apiLevel = null, jobs = null;
|
||||
|
||||
if (Settings.Default.Decode_NoSrc)
|
||||
keyNoSrc = DecompileKeys.NoSource;
|
||||
@@ -143,10 +143,10 @@ namespace APKToolGUI
|
||||
if (Settings.Default.Decode_SetApiLevel)
|
||||
apiLevel = String.Format("{0} {1}", DecompileKeys.ApiLevel, Settings.Default.Decode_ApiLevel);
|
||||
if (Settings.Default.Decode_SetJobs)
|
||||
apiLevel = String.Format("{0} {1}", DecompileKeys.Jobs, Settings.Default.Decode_Jobs);
|
||||
jobs = String.Format("{0} {1}", DecompileKeys.Jobs, Settings.Default.Decode_Jobs);
|
||||
keyOutputDir = String.Format("{0} \"{1}\"", DecompileKeys.OutputDir, outputDir);
|
||||
|
||||
string args = String.Format($"d{keyNoSrc}{keyNoRes}{keyForce}{onlyMainClasses}{noDebugInfo}{keyMatchOriginal}{keyFramePath}{keyKeepBrokenRes}{apiLevel}{keyOutputDir} \"{inputPath}\"");
|
||||
string args = String.Format($"d{keyNoSrc}{keyNoRes}{keyForce}{onlyMainClasses}{noDebugInfo}{keyMatchOriginal}{keyFramePath}{keyKeepBrokenRes}{apiLevel}{jobs}{keyOutputDir} \"{inputPath}\"");
|
||||
|
||||
Log.d("Apktool CMD: " + _jarPath + " " + args);
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace APKToolGUI
|
||||
|
||||
public int Build(string inputFolder, string outputFile)
|
||||
{
|
||||
string keyForceAll = null, keyAapt = null, keyCopyOriginal = null, noCrunch = null, keyFramePath = null, keyOutputAppPath = null, apiLevel = null, useAapt2 = null, netSecConf = null;
|
||||
string keyForceAll = null, keyAapt = null, keyCopyOriginal = null, noCrunch = null, keyFramePath = null, keyOutputAppPath = null, apiLevel = null, jobs = null, useAapt2 = null, netSecConf = null;
|
||||
|
||||
if (Settings.Default.Build_ForceAll)
|
||||
keyForceAll = BuildKeys.ForceAll;
|
||||
@@ -206,14 +206,14 @@ namespace APKToolGUI
|
||||
if (Settings.Default.Build_SetApiLevel)
|
||||
apiLevel = String.Format("{0} {1}", BuildKeys.ApiLevel, Settings.Default.Build_ApiLevel);
|
||||
if (Settings.Default.Build_SetJobs)
|
||||
apiLevel = String.Format("{0} {1}", BuildKeys.Jobs, Settings.Default.Build_Jobs);
|
||||
jobs = String.Format("{0} {1}", BuildKeys.Jobs, Settings.Default.Build_Jobs);
|
||||
if (Settings.Default.Build_UseAapt2)
|
||||
useAapt2 = BuildKeys.UseAapt2;
|
||||
if (Settings.Default.Build_NetSecConf)
|
||||
netSecConf = BuildKeys.NetSecConf;
|
||||
keyOutputAppPath = String.Format("{0} \"{1}\"", BuildKeys.OutputAppPath, outputFile);
|
||||
|
||||
string args = String.Format($"b{keyForceAll}{keyAapt}{keyCopyOriginal}{noCrunch}{keyFramePath}{apiLevel}{useAapt2}{netSecConf}{keyOutputAppPath} \"{inputFolder}\"");
|
||||
string args = String.Format($"b{keyForceAll}{keyAapt}{keyCopyOriginal}{noCrunch}{keyFramePath}{apiLevel}{jobs}{useAapt2}{netSecConf}{keyOutputAppPath} \"{inputFolder}\"");
|
||||
|
||||
Log.d("Apktool CMD: " + _jarPath + " " + args);
|
||||
|
||||
|
||||
@@ -205,14 +205,17 @@ namespace APKToolGUI
|
||||
ToLog(ApktoolEventType.Success, Language.Done);
|
||||
ToStatus(Language.Done, Resources.done);
|
||||
}
|
||||
#if DEBUG
|
||||
catch (Exception ex)
|
||||
{
|
||||
#if DEBUG
|
||||
ToLog(ApktoolEventType.Warning, Language.ErrorGettingApkInfo + "\n" + ex.ToString());
|
||||
#else
|
||||
ToLog(ApktoolEventType.Warning, Language.ErrorGettingApkInfo);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
catch (Exception)
|
||||
{
|
||||
ToLog(ApktoolEventType.Warning, Language.ErrorGettingApkInfo);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private async Task<ApkParseResult> ParseApkInBackgroundAsync(string file, string splitPath)
|
||||
@@ -1235,7 +1238,7 @@ namespace APKToolGUI
|
||||
Running(Language.Signing);
|
||||
|
||||
string outputFile = input;
|
||||
if (Settings.Default.Zipalign_UseOutputDir && !IgnoreOutputDirContextMenu)
|
||||
if (Settings.Default.Sign_UseOutputDir && !IgnoreOutputDirContextMenu)
|
||||
outputFile = Path.Combine(Settings.Default.Sign_OutputDir, Path.GetFileName(input));
|
||||
if (!Settings.Default.Sign_OverwriteInputFile)
|
||||
outputFile = PathUtils.GetDirectoryNameWithoutExtension(outputFile) + "_signed.apk";
|
||||
@@ -1716,4 +1719,4 @@ namespace APKToolGUI
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace APKToolGUI.Handlers
|
||||
string apkFile = null;
|
||||
if (e.DropOneByEnd(file => apkFile = file, apks))
|
||||
{
|
||||
main.smaliBrowseInputDirTxtBox.Text = apkFile;
|
||||
main.fileTxtBox.Text = apkFile;
|
||||
main.basicInfoTabPage.BackColor = PanelBackColor();
|
||||
await main.GetApkInfo(apkFile);
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace APKToolGUI.Handlers
|
||||
{
|
||||
string inputFile = Settings.Default.Sign_InputFile;
|
||||
string outputFile = inputFile;
|
||||
if (Settings.Default.Zipalign_UseOutputDir)
|
||||
if (Settings.Default.Sign_UseOutputDir)
|
||||
outputFile = Path.Combine(Settings.Default.Sign_OutputDir, Path.GetFileName(inputFile));
|
||||
|
||||
if (File.Exists(outputFile))
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace APKToolGUI.Handlers
|
||||
main = Main;
|
||||
main.button_SIGN_BrowsePublicKey.Click += Button_SIGN_BrowsePublicKey_Click;
|
||||
main.button_SIGN_BrowsePrivateKey.Click += Button_SIGN_BrowsePrivateKey_Click;
|
||||
main.button_SIGN_BrowsePrivateKey.Click += Button_SIGN_BrowsePrivateKey_Click;
|
||||
main.button_SIGN_BrowseInputFile.Click += Button_SIGN_BrowseInputFile_Click;
|
||||
main.button_SIGN_BrowseOutputFile.Click += Button_SIGN_BrowseOutputFile_Click;
|
||||
main.schemev1ComboBox.SelectedIndexChanged += SchemeComboBox_SelectedIndexChanged;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Java
|
||||
|
||||
public JarProcess(string javaPath, string jarPath)
|
||||
{
|
||||
JavaPath = javaPath.Equals("java") ? "" : javaPath;
|
||||
JavaPath = string.IsNullOrWhiteSpace(javaPath) ? "java" : javaPath;
|
||||
JarPath = jarPath;
|
||||
Initialize();
|
||||
}
|
||||
@@ -38,8 +38,9 @@ namespace Java
|
||||
if (Settings.Default.UseCustomJVMArgs)
|
||||
customArgs = Settings.Default.CustomJVMArgs;
|
||||
|
||||
StartInfo.Arguments = String.Format("-jar {0} \"{1}\" {2}", customArgs, JarPath, args);
|
||||
Debug.WriteLine(String.Format("-jar {0} \"{1}\" {2}", customArgs, JarPath, args));
|
||||
string jvmArgs = string.IsNullOrWhiteSpace(customArgs) ? string.Empty : customArgs.Trim() + " ";
|
||||
StartInfo.Arguments = String.Format("{0}-jar \"{1}\" {2}", jvmArgs, JarPath, args);
|
||||
Debug.WriteLine(StartInfo.Arguments);
|
||||
return base.Start();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,12 @@ namespace SaveToGameWpf.Logic.Utils
|
||||
public static void CheckDragEnter(this DragEventArgs e, params string[] extensions)
|
||||
{
|
||||
string[] files = e.GetFilesDrop();
|
||||
if (files.Length == 0)
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
return;
|
||||
}
|
||||
|
||||
if (extensions == null && Directory.Exists(files[0]))
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
else if (extensions != null && extensions.Any(ext => files[0].EndsWith(ext, StringComparison.Ordinal)))
|
||||
@@ -49,12 +55,18 @@ namespace SaveToGameWpf.Logic.Utils
|
||||
public static bool CheckDragOver(this DragEventArgs e, params string[] extensions)
|
||||
{
|
||||
string[] files = e.GetFilesDrop();
|
||||
if (files.Length == 0)
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (extensions == null && Directory.Exists(files[0]))
|
||||
{
|
||||
e.Effect = DragDropEffects.Move;
|
||||
return true;
|
||||
}
|
||||
else if (files.Length == 1 && extensions.Any(ext => files[0].EndsWith(ext, StringComparison.Ordinal)))
|
||||
else if (extensions != null && files.Length == 1 && extensions.Any(ext => files[0].EndsWith(ext, StringComparison.Ordinal)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Move;
|
||||
return true;
|
||||
@@ -68,6 +80,11 @@ namespace SaveToGameWpf.Logic.Utils
|
||||
public static bool CheckManyDragOver(this DragEventArgs e, params string[] extensions)
|
||||
{
|
||||
string[] files = e.GetFilesDrop();
|
||||
if (files.Length == 0)
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (extensions == null && Directory.Exists(files[0]))
|
||||
{
|
||||
@@ -87,6 +104,9 @@ namespace SaveToGameWpf.Logic.Utils
|
||||
public static bool DropOneByEnd(this DragEventArgs e, Action<string> onSuccess, params string[] extensions)
|
||||
{
|
||||
string[] files = e.GetFilesDrop();
|
||||
if (files.Length == 0)
|
||||
return false;
|
||||
|
||||
if (extensions == null && Directory.Exists(files[0]))
|
||||
{
|
||||
onSuccess(files[0]);
|
||||
@@ -103,6 +123,9 @@ namespace SaveToGameWpf.Logic.Utils
|
||||
|
||||
public static bool DropManyByEnd(this DragEventArgs e, Action<string[]> onSuccess, params string[] extensions)
|
||||
{
|
||||
if (extensions == null || extensions.Length == 0)
|
||||
return false;
|
||||
|
||||
foreach (string apk in extensions)
|
||||
{
|
||||
Debug.WriteLine(apk);
|
||||
|
||||
@@ -16,7 +16,7 @@ If you remain unsure, you can compile the app yourself or refrain from using it
|
||||
|
||||
# Requirements
|
||||
- Windows 7 32-bit/64-bit and above
|
||||
- [Java](https://www.java.com/en/) or [JDK](https://www.oracle.com/java/technologies/downloads/) 8 or above. Using latest JDK is not really necessary. Java 8 and 17 (long-term support release) is enough. Use 64-bit version if your system is 64-bit
|
||||
- [Java](https://www.java.com/en/) or [JDK](https://www.oracle.com/java/technologies/downloads/) 8 or above. Using latest JDK is not really necessary. Java 8 and 25 (long-term support release) is enough. Use 64-bit version if your system is 64-bit
|
||||
- [.NET Framework 4.8](https://dotnet.microsoft.com/en-us/download/dotnet-framework/net48) (Windows 8 and above already have it preinstalled)
|
||||
|
||||
# Features
|
||||
@@ -109,7 +109,7 @@ No, these features are also beyond the scope of this tool. I do not support or c
|
||||
# Development
|
||||
This project is written in C#
|
||||
|
||||
Use Visual Studio 2019 and above. NET Framework 4.8 SDK is required
|
||||
Use Visual Studio 2022 and above. NET Framework 4.8 SDK is required
|
||||
|
||||
# Credits
|
||||
- AndnixSH
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
3.3.2.2
|
||||
- Updated APKEditor to 1.4.7
|
||||
- Updated Apktool to 3.0.1
|
||||
- Updated ADB to 37.0.0-14910828
|
||||
|
||||
3.3.2.1
|
||||
- Updated APKEditor to 1.4.5
|
||||
- Updated Apktool to 2.12.1
|
||||
|
||||
Reference in New Issue
Block a user