diff options
| author | Xavier Ducrohet <xav@android.com> | 2009-08-25 20:01:56 -0700 |
|---|---|---|
| committer | Xavier Ducrohet <xav@android.com> | 2009-08-26 14:58:56 -0700 |
| commit | c364a52cd89a019d5eb503f3a269ff8e4feee644 (patch) | |
| tree | a57e13c53939d37ebd02ae859ab2729b885385bf /anttasks/src | |
| parent | 0984d4efe5cbaee1e833a7f7ce817bf6909ff024 (diff) | |
| download | sdk-c364a52cd89a019d5eb503f3a269ff8e4feee644.zip sdk-c364a52cd89a019d5eb503f3a269ff8e4feee644.tar.gz sdk-c364a52cd89a019d5eb503f3a269ff8e4feee644.tar.bz2 | |
Make ApkBuilder create filenames supported by older rules.
'ant install' must know the debug apk filename so newer naming scheme breaks
on older rule files (1.5 and earlier).
The fix is to check for the presence of the property naming the debug,
signed, unaligned package. If the property is present, then we use
the new naming scheme ({base}[-{config}]-debug-unaligned.apk), else we use
the old one ({base}-[-{config}]-debug.apk).
Also merge the install/reinstall targets, since 'adb install -r <file>'
works even if the apk was not yet installed.
Change-Id: Id0670610a6539a3f48c955756955f950039c3cd0
Diffstat (limited to 'anttasks/src')
| -rw-r--r-- | anttasks/src/com/android/ant/ApkBuilderTask.java | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/anttasks/src/com/android/ant/ApkBuilderTask.java b/anttasks/src/com/android/ant/ApkBuilderTask.java index b2c445d..e062fed 100644 --- a/anttasks/src/com/android/ant/ApkBuilderTask.java +++ b/anttasks/src/com/android/ant/ApkBuilderTask.java @@ -205,8 +205,26 @@ public class ApkBuilderTask extends Task { // for reuse by other targets (signing/zipaligning) Path path = new Path(antProject); + // The createApk method uses mBaseName for the base name of the packages (resources + // and apk files). + // The generated apk file name is + // debug: {base}[-{config}]-debug-unaligned.apk + // release: {base}[-{config}]-unsigned.apk + // Unfortunately for 1.5 projects and before the 'install' ant target expects the name + // of the default debug package to be {base}-debug.apk + // In order to support those package, we look for the 'out-debug-unaligned-package' + // property. If this exist, then we generate {base}[-{config}]-debug-unaligned.apk + // otherwise we generate {base}[-{config}]-debug.apk + // FIXME: Make apkbuilder export the package name used instead of + // having to keep apkbuilder and the rules file in sync + String debugPackageSuffix = "-debug-unaligned.apk"; + if (antProject.getProperty("out-debug-unaligned-package") == null) { + debugPackageSuffix = "-debug.apk"; + } + // first do a full resource package - createApk(apkBuilder, null /*configName*/, null /*resourceFilter*/, path); + createApk(apkBuilder, null /*configName*/, null /*resourceFilter*/, path, + debugPackageSuffix); // now see if we need to create file with filtered resources. // Get the project base directory. @@ -219,7 +237,8 @@ public class ApkBuilderTask extends Task { Map<String, String> apkFilters = apkSettings.getResourceFilters(); if (apkFilters.size() > 0) { for (Entry<String, String> entry : apkFilters.entrySet()) { - createApk(apkBuilder, entry.getKey(), entry.getValue(), path); + createApk(apkBuilder, entry.getKey(), entry.getValue(), path, + debugPackageSuffix); } } } @@ -244,11 +263,12 @@ public class ApkBuilderTask extends Task { * @param resourceFilter the resource configuration filter to pass to aapt (if configName is * non null) * @param path Ant {@link Path} to which add the generated APKs as {@link PathElement} + * @param debugPackageSuffix suffix for the debug packages. * @throws FileNotFoundException * @throws ApkCreationException */ private void createApk(ApkBuilderImpl apkBuilder, String configName, String resourceFilter, - Path path) + Path path, String debugPackageSuffix) throws FileNotFoundException, ApkCreationException { // All the files to be included in the archive have already been prep'ed up, except // the resource package. @@ -274,7 +294,7 @@ public class ApkBuilderTask extends Task { } if (mSigned) { - filename = filename + "-debug-unaligned.apk"; + filename = filename + debugPackageSuffix; } else { filename = filename + "-unsigned.apk"; } |
