Prevent ugly "Content is not allowed in prolog" warning
- fixes:
@@ -296,25 +296,12 @@ public class Androlib {
}
new File(appDir, APK_DIRNAME).mkdirs();
- buildSources(appDir);
- buildNonDefaultSources(appDir);
-
File manifest = new File(appDir, "AndroidManifest.xml");
File manifestOriginal = new File(appDir, "AndroidManifest.xml.orig");
- if (manifest.isFile() && manifest.exists()) {
- try {
-
- if (manifestOriginal.exists()) {
- manifestOriginal.delete();
- }
- FileUtils.copyFile(manifest, manifestOriginal);
- ResXmlPatcher.fixingPublicAttrsInProviderAttributes(manifest);
- } catch (IOException ex) {
- throw new AndrolibException(ex.getMessage());
- }
- }
-
+ buildSources(appDir);
+ buildNonDefaultSources(appDir);
+ buildManifestFile(appDir, manifest, manifestOriginal);
buildResources(appDir, meta.usesFramework);
buildLib(appDir);
buildLibs(appDir);
@@ -327,7 +314,7 @@ public class Androlib {
// we copied the AndroidManifest.xml to AndroidManifest.xml.orig so we can edit it
// lets restore the unedited one, to not change the original
- if (manifest.isFile() && manifest.exists()) {
+ if (manifest.isFile() && manifest.exists() && manifestOriginal.isFile()) {
try {
if (new File(appDir, "AndroidManifest.xml").delete()) {
FileUtils.moveFile(manifestOriginal, manifest);
@@ -338,6 +325,26 @@ public class Androlib {
}
}
+ private void buildManifestFile(File appDir, File manifest, File manifestOriginal)
+ throws AndrolibException {
+
+ // If we decoded in "raw", we cannot patch AndroidManifest
+ if (new File(appDir, "resources.arsc").exists()) {
+ return;
+ }
+ if (manifest.isFile() && manifest.exists()) {
+ try {
+ if (manifestOriginal.exists()) {
+ manifestOriginal.delete();
+ }
+ FileUtils.copyFile(manifest, manifestOriginal);
+ ResXmlPatcher.fixingPublicAttrsInProviderAttributes(manifest);
+ } catch (IOException ex) {
+ throw new AndrolibException(ex.getMessage());
+ }
+ }
+ }
+
public void buildSources(File appDir)
throws AndrolibException {
if (!buildSourcesRaw(appDir, "classes.dex") && !buildSourcesSmali(appDir, "smali", "classes.dex")) {
