mirror of
https://github.com/AndnixSH/APKToolGUI.git
synced 2026-05-04 11:02:27 +00:00
Fix ApkTool errors after decompile: Change sparseResources to false
This commit is contained in:
@@ -12,9 +12,9 @@ namespace APKToolGUI.ApkTool
|
||||
{
|
||||
public class ApkFixer
|
||||
{
|
||||
public static bool FixAndroidManifest(string path)
|
||||
public static bool FixAndroidManifest(string decompilePath)
|
||||
{
|
||||
string manifestPath = Path.Combine(path, "AndroidManifest.xml");
|
||||
string manifestPath = Path.Combine(decompilePath, "AndroidManifest.xml");
|
||||
if (File.Exists(manifestPath))
|
||||
{
|
||||
string maniFestText = File.ReadAllText(manifestPath);
|
||||
@@ -26,13 +26,27 @@ namespace APKToolGUI.ApkTool
|
||||
maniFestText = maniFestText.Replace("android:localeConfig=\"@xml/locales_config\"", "");
|
||||
maniFestText = maniFestText.Replace("STAMP_TYPE_DISTRIBUTION_APK", "STAMP_TYPE_STANDALONE_APK");
|
||||
|
||||
File.WriteAllText(Path.Combine(path, "AndroidManifest.xml"), maniFestText);
|
||||
File.WriteAllText(manifestPath, maniFestText);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool FixApktoolYml(string decompilePath)
|
||||
{
|
||||
string ymlPath = Path.Combine(decompilePath, "apktool.yml");
|
||||
if (File.Exists(ymlPath))
|
||||
{
|
||||
string yml = File.ReadAllText(ymlPath);
|
||||
yml = yml.Replace("sparseResources: true", "sparseResources: false");
|
||||
|
||||
File.WriteAllText(ymlPath, yml);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool RemoveApkToolDummies(string path)
|
||||
{
|
||||
string resPath = Path.Combine(path, "res", "values");
|
||||
@@ -43,24 +57,5 @@ namespace APKToolGUI.ApkTool
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool ChangeSdkTo29(string path)
|
||||
{
|
||||
string ymlPath = Path.Combine(path, "apktool.yml");
|
||||
if (File.Exists(ymlPath))
|
||||
{
|
||||
string ymll = File.ReadAllText(ymlPath);
|
||||
|
||||
int sdk = 30;
|
||||
int.TryParse(StringExt.Regex(@"(?<= targetSdkVersion: \')(.*?)(?=\')", ymll), out sdk);
|
||||
if (sdk >= 30)
|
||||
{
|
||||
ymll = ymll.Replace("targetSdkVersion: '" + sdk + "'", "targetSdkVersion: '29'");
|
||||
File.WriteAllText(ymlPath, ymll);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -751,6 +751,8 @@ namespace APKToolGUI
|
||||
{
|
||||
if (ApkFixer.FixAndroidManifest(outputDir))
|
||||
ToLog(ApktoolEventType.None, Language.FixAndroidManifest);
|
||||
if (ApkFixer.FixApktoolYml(outputDir))
|
||||
ToLog(ApktoolEventType.None, Language.FixApktoolYml);
|
||||
if (ApkFixer.RemoveApkToolDummies(outputDir))
|
||||
ToLog(ApktoolEventType.None, Language.RemoveApkToolDummies);
|
||||
}
|
||||
@@ -892,6 +894,8 @@ namespace APKToolGUI
|
||||
{
|
||||
if (ApkFixer.FixAndroidManifest(outputDir))
|
||||
ToLog(ApktoolEventType.None, Language.FixAndroidManifest);
|
||||
if (ApkFixer.FixApktoolYml(outputDir))
|
||||
ToLog(ApktoolEventType.None, Language.FixApktoolYml);
|
||||
if (ApkFixer.RemoveApkToolDummies(outputDir))
|
||||
ToLog(ApktoolEventType.None, Language.RemoveApkToolDummies);
|
||||
}
|
||||
|
||||
@@ -2302,7 +2302,7 @@
|
||||
<value>454, 16</value>
|
||||
</metadata>
|
||||
<data name="checkBox_DECODE_FixError.ToolTip" xml:space="preserve">
|
||||
<value>It will remove isSplitRequired, extractNativeLibs, useEmbeddedDex, APKTOOL_DUMMY and set </value>
|
||||
<value>It will remove extractNativeLibs, useEmbeddedDex, APKTOOL_DUMMY, split related attributes and set sparseResources to false</value>
|
||||
</data>
|
||||
<data name=">>checkBox_DECODE_FixError.Name" xml:space="preserve">
|
||||
<value>checkBox_DECODE_FixError</value>
|
||||
|
||||
+9
@@ -762,6 +762,15 @@ namespace APKToolGUI.Languages {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Fixed apktool.yml.
|
||||
/// </summary>
|
||||
internal static string FixApktoolYml {
|
||||
get {
|
||||
return ResourceManager.GetString("FixApktoolYml", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Folder does not exist.
|
||||
/// </summary>
|
||||
|
||||
@@ -531,4 +531,7 @@
|
||||
<data name="OpenDecFolder" xml:space="preserve">
|
||||
<value>Open decompile output folder</value>
|
||||
</data>
|
||||
<data name="FixApktoolYml" xml:space="preserve">
|
||||
<value>Fixed apktool.yml</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user