only use --forced-package-id if prebuilt aapt is used

This commit is contained in:
Connor Tumbleson 2013-03-29 14:49:04 -05:00
parent d8b774864c
commit be77354859

View File

@ -323,40 +323,42 @@ final public class AndrolibResources {
mPackageId = id; mPackageId = id;
} }
public void aaptPackage(File apkFile, File manifest, File resDir, public void aaptPackage(File apkFile, File manifest, File resDir,
File rawDir, File assetDir, File[] include, File rawDir, File assetDir, File[] include,
HashMap<String, Boolean> flags, String aaptPath) HashMap<String, Boolean> flags, String aaptPath)
throws AndrolibException { throws AndrolibException {
List<String> cmd = new ArrayList<String>(); boolean customAapt = false;
List<String> cmd = new ArrayList<String>();
// path for aapt binary // path for aapt binary
if (!aaptPath.isEmpty()) { if (!aaptPath.isEmpty()) {
File aaptFile = new File(aaptPath); File aaptFile = new File(aaptPath);
if (aaptFile.canRead() && aaptFile.exists()) { if (aaptFile.canRead() && aaptFile.exists()) {
aaptFile.setExecutable(true); aaptFile.setExecutable(true);
cmd.add(aaptFile.getPath()); cmd.add(aaptFile.getPath());
customAapt = true;
if (flags.get("verbose")) { if (flags.get("verbose")) {
LOGGER.info(aaptFile.getPath() LOGGER.info(aaptFile.getPath()
+ " being used as aapt location."); + " being used as aapt location.");
} }
} else { } else {
LOGGER.warning("aapt location could not be found. Defaulting back to default"); LOGGER.warning("aapt location could not be found. Defaulting back to default");
try { try {
cmd.add(getAaptBinaryFile().getAbsolutePath()); cmd.add(getAaptBinaryFile().getAbsolutePath());
} catch (BrutException ignored) { } catch (BrutException ignored) {
cmd.add("aapt"); cmd.add("aapt");
} }
} }
} else { } else {
try { try {
cmd.add(getAaptBinaryFile().getAbsolutePath()); cmd.add(getAaptBinaryFile().getAbsolutePath());
} catch (BrutException ignored) { } catch (BrutException ignored) {
cmd.add("aapt"); cmd.add("aapt");
} }
} }
cmd.add("p"); cmd.add("p");
@ -369,7 +371,10 @@ final public class AndrolibResources {
if (flags.get("debug")) { // inject debuggable="true" into manifest if (flags.get("debug")) { // inject debuggable="true" into manifest
cmd.add("--debug-mode"); cmd.add("--debug-mode");
} }
if (mPackageId != null) {
// force package id so that some frameworks build with correct id
// disable if user adds own aapt (can't know if they have this feature)
if (mPackageId != null && customAapt == false) {
cmd.add("--forced-package-id"); cmd.add("--forced-package-id");
cmd.add(mPackageId); cmd.add(mPackageId);
} }