aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--anttasks/src/com/android/ant/AaptExecLoopTask.java17
-rw-r--r--anttasks/src/com/android/ant/ApkBuilderTask.java18
-rw-r--r--anttasks/src/com/android/ant/SetupTask.java12
-rw-r--r--apkbuilder/src/com/android/apkbuilder/internal/ApkBuilderImpl.java24
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditor.java5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java7
-rw-r--r--files/ant_lib_rules_r3.xml141
-rw-r--r--files/ant_rules_r3.xml479
-rw-r--r--files/ant_test_rules_r3.xml459
-rw-r--r--files/sdk.properties4
-rw-r--r--sdklauncher/sdklauncher.c83
-rw-r--r--sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java81
-rw-r--r--sdkmanager/app/src/com/android/sdkmanager/Main.java12
-rw-r--r--templates/build.template74
14 files changed, 1308 insertions, 108 deletions
diff --git a/anttasks/src/com/android/ant/AaptExecLoopTask.java b/anttasks/src/com/android/ant/AaptExecLoopTask.java
index 9fe2170..09354c0 100644
--- a/anttasks/src/com/android/ant/AaptExecLoopTask.java
+++ b/anttasks/src/com/android/ant/AaptExecLoopTask.java
@@ -79,6 +79,7 @@ public final class AaptExecLoopTask extends Task {
private String mCommand;
private boolean mForce = true; // true due to legacy reasons
private boolean mVerbose = false;
+ private int mVersionCode = 0;
private String mManifest;
private ArrayList<Path> mResources;
private String mAssets;
@@ -120,6 +121,17 @@ public final class AaptExecLoopTask extends Task {
mVerbose = verbose;
}
+ public void setVersioncode(String versionCode) {
+ if (versionCode.length() > 0) {
+ try {
+ mVersionCode = Integer.decode(versionCode);
+ } catch (NumberFormatException e) {
+ System.out.println(String.format(
+ "WARNING: Ignoring invalid version code value '%s'.", versionCode));
+ }
+ }
+ }
+
/**
* Sets the value of the "manifest" attribute.
* @param manifest the value.
@@ -356,6 +368,11 @@ public final class AaptExecLoopTask extends Task {
task.createArg().setValue("--auto-add-overlay");
}
+ if (mVersionCode != 0) {
+ task.createArg().setValue("--version-code");
+ task.createArg().setValue(Integer.toString(mVersionCode));
+ }
+
// manifest location
if (mManifest != null) {
task.createArg().setValue("-M");
diff --git a/anttasks/src/com/android/ant/ApkBuilderTask.java b/anttasks/src/com/android/ant/ApkBuilderTask.java
index 3fdf4d5..9067ec7 100644
--- a/anttasks/src/com/android/ant/ApkBuilderTask.java
+++ b/anttasks/src/com/android/ant/ApkBuilderTask.java
@@ -46,6 +46,7 @@ public class ApkBuilderTask extends Task {
private boolean mVerbose = false;
private boolean mSigned = true;
private boolean mDebug = false;
+ private String mAbiFilter = null;
private final ArrayList<Path> mZipList = new ArrayList<Path>();
private final ArrayList<Path> mFileList = new ArrayList<Path>();
@@ -101,6 +102,21 @@ public class ApkBuilderTask extends Task {
}
/**
+ * Sets an ABI filter. If non <code>null</code>, then only native libraries matching the given
+ * ABI will be packaged with the APK.
+ * @param abiFilter the ABI to accept (and reject all other). If null or empty string, no ABIs
+ * are rejected. This must be a single ABI name as defined by the Android NDK. For a list
+ * of valid ABI names, see $NDK/docs/CPU-ARCH-ABIS.TXT
+ */
+ public void setAbifilter(String abiFilter) {
+ if (abiFilter != null && abiFilter.length() > 0) {
+ mAbiFilter = abiFilter.trim();
+ } else {
+ mAbiFilter = null;
+ }
+ }
+
+ /**
* Returns an object representing a nested <var>zip</var> element.
*/
public Object createZip() {
@@ -208,7 +224,7 @@ public class ApkBuilderTask extends Task {
for (Path pathList : mNativeList) {
for (String path : pathList.list()) {
ApkBuilderImpl.processNativeFolder(new File(path), mDebug,
- mNativeLibraries);
+ mNativeLibraries, mVerbose, mAbiFilter);
}
}
diff --git a/anttasks/src/com/android/ant/SetupTask.java b/anttasks/src/com/android/ant/SetupTask.java
index e1ee825..a840783 100644
--- a/anttasks/src/com/android/ant/SetupTask.java
+++ b/anttasks/src/com/android/ant/SetupTask.java
@@ -65,7 +65,7 @@ import javax.xml.xpath.XPathExpressionException;
*/
public final class SetupTask extends ImportTask {
/** current max version of the Ant rules that is supported */
- private final static int ANT_RULES_MAX_VERSION = 2;
+ private final static int ANT_RULES_MAX_VERSION = 3;
// legacy main rules file.
private final static String RULES_LEGACY_MAIN = "android_rules.xml";
@@ -183,9 +183,13 @@ public final class SetupTask extends ImportTask {
int antBuildVersion = androidTarget.getProperty(SdkConstants.PROP_SDK_ANT_BUILD_REVISION,
1);
if (antBuildVersion > ANT_RULES_MAX_VERSION) {
- throw new BuildException(String.format(
- "The project target (%1$s) requires a more recent version of the tools. Please update.",
- androidTarget.getName()));
+ antBuildVersion = ANT_RULES_MAX_VERSION;
+ System.out.println("\n\n\n"
+ + "***********************************************************\n"
+ + "WARNING: This platform requires Ant build rules not supported by your SDK Tools.\n"
+ + "WARNING: Attempting to use older build rules instead, but result may not be correct.\n"
+ + "WARNING: Please update to the newest revisions of the SDK Tools.\n"
+ + "***********************************************************\n\n\n");
}
// check if the project is a library
diff --git a/apkbuilder/src/com/android/apkbuilder/internal/ApkBuilderImpl.java b/apkbuilder/src/com/android/apkbuilder/internal/ApkBuilderImpl.java
index d8e0123..3189c41 100644
--- a/apkbuilder/src/com/android/apkbuilder/internal/ApkBuilderImpl.java
+++ b/apkbuilder/src/com/android/apkbuilder/internal/ApkBuilderImpl.java
@@ -148,7 +148,8 @@ public final class ApkBuilderImpl {
throw new WrongOptionException("Missing value for -nf");
}
- processNativeFolder(new File(args[index++]), mDebugMode, nativeLibraries);
+ processNativeFolder(new File(args[index++]), mDebugMode, nativeLibraries,
+ mVerbose, null /*abiFilter*/);
} else if ("-storetype".equals(argument)) {
// quick check on the next argument.
if (index == args.length) {
@@ -317,19 +318,38 @@ public final class ApkBuilderImpl {
* <p/>The root folder must include folders that include .so files.
* @param root the native root folder.
* @param nativeLibraries the collection to add native libraries to.
+ * @param verbose verbose mode.
+ * @param abiFilter optional ABI filter. If non-null only the given ABI is included.
* @throws ApkCreationException
*/
public static void processNativeFolder(File root, boolean debugMode,
- Collection<ApkFile> nativeLibraries) throws ApkCreationException {
+ Collection<ApkFile> nativeLibraries, boolean verbose, String abiFilter)
+ throws ApkCreationException {
if (root.isDirectory() == false) {
throw new ApkCreationException(root.getAbsolutePath() + " is not a folder!");
}
File[] abiList = root.listFiles();
+ if (verbose) {
+ System.out.println("Processing native folder: " + root.getAbsolutePath());
+ if (abiFilter != null) {
+ System.out.println("ABI Filter: " + abiFilter);
+ }
+ }
+
if (abiList != null) {
for (File abi : abiList) {
if (abi.isDirectory()) { // ignore files
+
+ // check the abi filter and reject all other ABIs
+ if (abiFilter != null && abiFilter.equals(abi.getName()) == false) {
+ if (verbose) {
+ System.out.println("Rejecting ABI " + abi.getName());
+ }
+ continue;
+ }
+
File[] libs = abi.listFiles();
if (libs != null) {
for (File lib : libs) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditor.java
index c059a41..a250c76 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditor.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditor.java
@@ -505,7 +505,10 @@ public class LayoutEditor extends AndroidEditor implements IShowEditorInput, IPa
IAndroidTarget target = currentSdk.getTarget(project);
if (target != null) {
AndroidTargetData data = currentSdk.getTargetData(target);
- desc = data.getLayoutDescriptors().getBaseViewDescriptor();
+ if (data != null) {
+ // data can be null when the target is still loading
+ desc = data.getLayoutDescriptors().getBaseViewDescriptor();
+ }
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java
index a13f3f2..fc6156d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java
@@ -246,9 +246,6 @@ public class DeviceView extends ViewPart implements IUiSelectionListener, IClien
@Override
public void createPartControl(Composite parent) {
mParentShell = parent.getShell();
- ClientData.setHprofDumpHandler(new HProfHandler(mParentShell));
- AndroidDebugBridge.addClientChangeListener(this);
- ClientData.setMethodProfilingHandler(new MethodProfilingHandler(mParentShell));
mDeviceList = new DevicePanel(DdmsPlugin.getImageLoader(), USE_SELECTED_DEBUG_PORT);
mDeviceList.createPanel(parent);
@@ -425,6 +422,10 @@ public class DeviceView extends ViewPart implements IUiSelectionListener, IClien
}
placeActions();
+
+ ClientData.setHprofDumpHandler(new HProfHandler(mParentShell));
+ AndroidDebugBridge.addClientChangeListener(this);
+ ClientData.setMethodProfilingHandler(new MethodProfilingHandler(mParentShell));
}
@Override
diff --git a/files/ant_lib_rules_r3.xml b/files/ant_lib_rules_r3.xml
new file mode 100644
index 0000000..c207308
--- /dev/null
+++ b/files/ant_lib_rules_r3.xml
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="android_rules" default="debug">
+
+ <!--
+ This rules file is meant to be imported by the custom Ant task:
+ com.android.ant.SetupTask
+
+ The following properties are put in place by the importing task:
+ android.jar, android.aidl, aapt, aidl, and dx
+
+ Additionnaly, the task sets up the following classpath reference:
+ android.target.classpath
+ This is used by the compiler task as the boot classpath.
+ -->
+
+ <!-- Custom tasks -->
+ <taskdef name="aaptexec"
+ classname="com.android.ant.AaptExecLoopTask"
+ classpathref="android.antlibs" />
+
+ <taskdef name="xpath"
+ classname="com.android.ant.XPathTask"
+ classpathref="android.antlibs" />
+
+ <!-- Properties -->
+
+ <!-- Tells adb which device to target. You can change this from the command line
+ by invoking "ant -Dadb.device.arg=-d" for device "ant -Dadb.device.arg=-e" for
+ the emulator. -->
+ <property name="adb.device.arg" value="" />
+
+ <property name="android.tools.dir" location="${sdk.dir}/tools" />
+ <!-- Name of the application package extracted from manifest file -->
+ <xpath input="AndroidManifest.xml" expression="/manifest/@package"
+ output="manifest.package" />
+
+ <!-- Input directories -->
+ <property name="source.dir" value="src" />
+ <property name="source.absolute.dir" location="${source.dir}" />
+ <property name="gen.dir" value="gen" />
+ <property name="gen.absolute.dir" location="${gen.dir}" />
+ <property name="resource.dir" value="res" />
+ <property name="resource.absolute.dir" location="${resource.dir}" />
+ <property name="asset.dir" value="assets" />
+ <property name="asset.absolute.dir" location="${asset.dir}" />
+
+ <!-- Directory for the third party java libraries -->
+ <property name="external.libs.dir" value="libs" />
+ <property name="external.libs.absolute.dir" location="${external.libs.dir}" />
+
+ <!-- Directory for the native libraries -->
+ <property name="native.libs.dir" value="libs" />
+ <property name="native.libs.absolute.dir" location="${native.libs.dir}" />
+
+ <!-- Output directories -->
+ <property name="out.dir" value="bin" />
+ <property name="out.absolute.dir" location="${out.dir}" />
+ <property name="out.classes.dir" value="${out.absolute.dir}/classes" />
+ <property name="out.classes.absolute.dir" location="${out.classes.dir}" />
+
+ <!-- Verbosity -->
+ <property name="verbose" value="false" />
+ <!-- This is needed by emma as it uses multilevel verbosity instead of simple 'true' or 'false'
+ The property 'verbosity' is not user configurable and depends exclusively on 'verbose'
+ value.-->
+ <condition property="verbosity" value="verbose" else="quiet">
+ <istrue value="${verbose}" />
+ </condition>
+
+ <!-- Tools -->
+ <condition property="exe" value=".exe" else=""><os family="windows" /></condition>
+
+ <!-- Emma configuration -->
+ <property name="emma.dir" value="${sdk.dir}/tools/lib" />
+ <path id="emma.lib">
+ <pathelement location="${emma.dir}/emma.jar" />
+ <pathelement location="${emma.dir}/emma_ant.jar" />
+ </path>
+ <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
+ <!-- End of emma configuration -->
+
+ <!-- Rules -->
+
+ <!-- Creates the output directories if they don't exist yet. -->
+ <target name="-dirs">
+ <echo>Creating output directories if needed...</echo>
+ <mkdir dir="${resource.absolute.dir}" />
+ <mkdir dir="${external.libs.absolute.dir}" />
+ <mkdir dir="${gen.absolute.dir}" />
+ <mkdir dir="${out.absolute.dir}" />
+ <mkdir dir="${out.classes.absolute.dir}" />
+ </target>
+
+ <!-- Generates the R.java file for this project's resources. -->
+ <target name="-resource-src" depends="-dirs">
+ <echo>Generating R.java / Manifest.java from the resources...</echo>
+ <aaptexec executable="${aapt}"
+ command="package"
+ verbose="${verbose}"
+ manifest="AndroidManifest.xml"
+ androidjar="${android.jar}"
+ rfolder="${gen.absolute.dir}">
+ <res path="${resource.absolute.dir}" />
+ </aaptexec>
+ </target>
+
+ <!-- Compiles this project's .java files into .class files. -->
+ <target name="compile" depends="-resource-src"
+ description="Compiles project's .java files into .class files">
+ <!-- If android rules are used for a test project, its classpath should include
+ tested project's location -->
+ <condition property="extensible.classpath"
+ value="${tested.project.absolute.dir}/bin/classes" else=".">
+ <isset property="tested.project.absolute.dir" />
+ </condition>
+ <javac encoding="ascii" target="1.5" debug="true" extdirs=""
+ destdir="${out.classes.absolute.dir}"
+ bootclasspathref="android.target.classpath"
+ verbose="${verbose}" classpath="${extensible.classpath}">
+ <src path="${source.absolute.dir}" />
+ <src path="${gen.absolute.dir}" />
+ <classpath>
+ <fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="clean" description="Removes output files created by other targets.">
+ <delete dir="${out.absolute.dir}" verbose="${verbose}" />
+ <delete dir="${gen.absolute.dir}" verbose="${verbose}" />
+ </target>
+
+ <target name="help">
+ <!-- displays starts at col 13
+ |13 80| -->
+ <echo>Android Ant Build. Available targets:</echo>
+ <echo> help: Displays this help.</echo>
+ <echo> clean: Removes output files created by other targets.</echo>
+ <echo> compile: Compiles project's .java files into .class files.</echo>
+ </target>
+</project>
diff --git a/files/ant_rules_r3.xml b/files/ant_rules_r3.xml
new file mode 100644
index 0000000..76f54e4
--- /dev/null
+++ b/files/ant_rules_r3.xml
@@ -0,0 +1,479 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="android_rules" default="debug">
+
+ <!--
+ This rules file is meant to be imported by the custom Ant task:
+ com.android.ant.SetupTask
+
+ The following properties are put in place by the importing task:
+ android.jar, android.aidl, aapt, aidl, and dx
+
+ Additionnaly, the task sets up the following classpath reference:
+ android.target.classpath
+ This is used by the compiler task as the boot classpath.
+ -->
+
+ <!-- Custom tasks -->
+ <taskdef name="aaptexec"
+ classname="com.android.ant.AaptExecLoopTask"
+ classpathref="android.antlibs" />
+
+ <taskdef name="apkbuilder"
+ classname="com.android.ant.ApkBuilderTask"
+ classpathref="android.antlibs" />
+
+ <taskdef name="xpath"
+ classname="com.android.ant.XPathTask"
+ classpathref="android.antlibs" />
+
+ <!-- Properties -->
+
+ <!-- Tells adb which device to target. You can change this from the command line
+ by invoking "ant -Dadb.device.arg=-d" for device "ant -Dadb.device.arg=-e" for
+ the emulator. -->
+ <property name="adb.device.arg" value="" />
+
+ <property name="android.tools.dir" location="${sdk.dir}/tools" />
+ <!-- Name of the application package extracted from manifest file -->
+ <xpath input="AndroidManifest.xml" expression="/manifest/@package"
+ output="manifest.package" />
+ <!-- Value of the debuggable attribute (Application node) extracted from manifest file -->
+ <xpath input="AndroidManifest.xml" expression="/manifest/application/@android:debuggable"
+ output="manifest.debuggable" default="false"/>
+
+ <!-- Input directories -->
+ <property name="source.dir" value="src" />
+ <property name="source.absolute.dir" location="${source.dir}" />
+ <property name="gen.dir" value="gen" />
+ <property name="gen.absolute.dir" location="${gen.dir}" />
+ <property name="resource.dir" value="res" />
+ <property name="resource.absolute.dir" location="${resource.dir}" />
+ <property name="asset.dir" value="assets" />
+ <property name="asset.absolute.dir" location="${asset.dir}" />
+
+ <!-- Directory for the third party java libraries -->
+ <property name="external.libs.dir" value="libs" />
+ <property name="external.libs.absolute.dir" location="${external.libs.dir}" />
+
+ <!-- Directory for the native libraries -->
+ <property name="native.libs.dir" value="libs" />
+ <property name="native.libs.absolute.dir" location="${native.libs.dir}" />
+
+ <!-- Output directories -->
+ <property name="out.dir" value="bin" />
+ <property name="out.absolute.dir" location="${out.dir}" />
+ <property name="out.classes.dir" value="${out.absolute.dir}/classes" />
+ <property name="out.classes.absolute.dir" location="${out.classes.dir}" />
+
+ <!-- Intermediate files -->
+ <property name="dex.file.name" value="classes.dex" />
+ <property name="intermediate.dex.file" location="${out.absolute.dir}/${dex.file.name}" />
+
+ <!-- The final package file to generate -->
+ <property name="out.debug.unaligned.package"
+ location="${out.absolute.dir}/${ant.project.name}-debug-unaligned.apk" />
+ <property name="out.debug.package"
+ location="${out.absolute.dir}/${ant.project.name}-debug.apk" />
+ <property name="out.unsigned.package"
+ location="${out.absolute.dir}/${ant.project.name}-unsigned.apk" />
+ <property name="out.unaligned.package"
+ location="${out.absolute.dir}/${ant.project.name}-unaligned.apk" />
+ <property name="out.release.package"
+ location="${out.absolute.dir}/${ant.project.name}-release.apk" />
+
+ <!-- set some properties used for filtering/override. If those weren't defined
+ before, then this will create them with empty values, which are then ignored
+ by the custom tasks receiving them. -->
+ <property name="version.code" value="" />
+ <property name="filter.abi" value="" />
+
+ <!-- Verbosity -->
+ <property name="verbose" value="false" />
+ <!-- This is needed by emma as it uses multilevel verbosity instead of simple 'true' or 'false'
+ The property 'verbosity' is not user configurable and depends exclusively on 'verbose'
+ value.-->
+ <condition property="verbosity" value="verbose" else="quiet">
+ <istrue value="${verbose}" />
+ </condition>
+ <!-- This is needed to switch verbosity of zipalign. Depends exclusively on 'verbose'
+ -->
+ <condition property="v.option" value="-v" else="">
+ <istrue value="${verbose}" />
+ </condition>
+ <!-- This is needed to switch verbosity of dx. Depends exclusively on 'verbose' -->
+ <condition property="verbose.option" value="--verbose" else="">
+ <istrue value="${verbose}" />
+ </condition>
+
+ <!-- Tools -->
+ <condition property="exe" value=".exe" else=""><os family="windows" /></condition>
+ <property name="adb" location="${android.tools.dir}/adb${exe}" />
+ <property name="zipalign" location="${android.tools.dir}/zipalign${exe}" />
+
+ <!-- Emma configuration -->
+ <property name="emma.dir" value="${sdk.dir}/tools/lib" />
+ <path id="emma.lib">
+ <pathelement location="${emma.dir}/emma.jar" />
+ <pathelement location="${emma.dir}/emma_ant.jar" />
+ </path>
+ <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
+ <!-- End of emma configuration -->
+
+ <!-- Macros -->
+
+ <!-- Configurable macro, which allows to pass as parameters output directory,
+ output dex filename and external libraries to dex (optional) -->
+ <macrodef name="dex-helper">
+ <element name="external-libs" optional="yes" />
+ <element name="extra-parameters" optional="yes" />
+ <sequential>
+ <echo>Converting compiled files and external libraries into ${intermediate.dex.file}...</echo>
+ <apply executable="${dx}" failonerror="true" parallel="true">
+ <arg value="--dex" />
+ <arg value="--output=${intermediate.dex.file}" />
+ <extra-parameters />
+ <arg line="${verbose.option}" />
+ <arg path="${out.classes.absolute.dir}" />
+ <fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
+ <path refid="android.libraries.jars" />
+ <external-libs />
+ </apply>
+ </sequential>
+ </macrodef>
+
+ <!-- This is macro that enable passing variable list of external jar files to ApkBuilder
+ Example of use:
+ <package-helper sign.package="true">
+ <extra-jars>
+ <jarfolder path="my_jars" />
+ <jarfile path="foo/bar.jar" />
+ <jarfolder path="your_jars" />
+ </extra-jars>
+ </package-helper> -->
+ <macrodef name="package-helper">
+ <attribute name="sign.package" />
+ <element name="extra-jars" optional="yes" />
+ <sequential>
+ <apkbuilder
+ outfolder="${out.absolute.dir}"
+ basename="${ant.project.name}"
+ signed="@{sign.package}"
+ debug="${manifest.debuggable}"
+ abifilter="${filter.abi}"
+ verbose="${verbose}">
+ <file path="${intermediate.dex.file}" />
+ <sourcefolder path="${source.absolute.dir}" />
+ <sourcefolder refid="android.libraries.src" />
+ <jarfolder path="${external.libs.absolute.dir}" />
+ <jarfolder refid="android.libraries.libs" />
+ <nativefolder path="${native.libs.absolute.dir}" />
+ <nativefolder refid="android.libraries.libs" />
+ <extra-jars/>
+ </apkbuilder>
+ </sequential>
+ </macrodef>
+
+ <!-- This is macro which zipaligns in.package and outputs it to out.package. Used by targets
+ debug, -debug-with-emma and release.-->
+ <macrodef name="zipalign-helper">
+ <attribute name="in.package" />
+ <attribute name="out.package" />
+ <sequential>
+ <echo>Running zip align on final apk...</echo>
+ <exec executable="${zipalign}" failonerror="true">
+ <arg line="${v.option}" />
+ <arg value="-f" />
+ <arg value="4" />
+ <arg path="@{in.package}" />
+ <arg path="@{out.package}" />
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <!-- This is macro used only for sharing code among two targets, -install and
+ -install-with-emma which do exactly the same but differ in dependencies -->
+ <macrodef name="install-helper">
+ <sequential>
+ <echo>Installing ${out.debug.package} onto default emulator or device...</echo>
+ <exec executable="${adb}" failonerror="true">
+ <arg line="${adb.device.arg}" />
+ <arg value="install" />
+ <arg value="-r" />
+ <arg path="${out.debug.package}" />
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <!-- Rules -->
+
+ <!-- Creates the output directories if they don't exist yet. -->
+ <target name="-dirs">
+ <echo>Creating output directories if needed...</echo>
+ <mkdir dir="${resource.absolute.dir}" />
+ <mkdir dir="${external.libs.absolute.dir}" />
+ <mkdir dir="${gen.absolute.dir}" />
+ <mkdir dir="${out.absolute.dir}" />
+ <mkdir dir="${out.classes.absolute.dir}" />
+ </target>
+
+ <!-- empty default pre-build target. Create a similar target in
+ your build.xml and it'll be called instead of this one. -->
+ <target name="-pre-build"/>
+
+ <!-- Generates the R.java file for this project's resources. -->
+ <target name="-resource-src" depends="-dirs, -pre-build">
+ <echo>Generating R.java / Manifest.java from the resources...</echo>
+ <aaptexec executable="${aapt}"
+ command="package"
+ verbose="${verbose}"
+ manifest="AndroidManifest.xml"
+ androidjar="${android.jar}"
+ rfolder="${gen.absolute.dir}">
+ <res path="${resource.absolute.dir}" />
+ </aaptexec>
+ </target>
+
+ <!-- Generates java classes from .aidl files. -->
+ <target name="-aidl" depends="-dirs">
+ <echo>Compiling aidl files into Java classes...</echo>
+ <apply executable="${aidl}" failonerror="true">
+ <arg value="-p${android.aidl}" />
+ <arg value="-I${source.absolute.dir}" />
+ <arg value="-o${gen.absolute.dir}" />
+ <fileset dir="${source.absolute.dir}">
+ <include name="**/*.aidl" />
+ </fileset>
+ </apply>
+ </target>
+
+ <!-- empty default pre-compile target. Create a similar target in
+ your build.xml and it'll be called instead of this one. -->
+ <target name="-pre-compile"/>
+
+ <!-- Compiles this project's .java files into .class files. -->
+ <target name="compile" depends="-resource-src, -aidl, -pre-compile"
+ description="Compiles project's .java files into .class files">
+ <!-- If android rules are used for a test project, its classpath should include
+ tested project's location -->
+ <condition property="extensible.classpath"
+ value="${tested.project.absolute.dir}/bin/classes" else=".">
+ <isset property="tested.project.absolute.dir" />
+ </condition>
+ <condition property="extensible.libs.classpath"
+ value="${tested.project.absolute.dir}/libs" else="./libs">
+ <isset property="tested.project.absolute.dir" />
+ </condition>
+ <javac encoding="ascii" target="1.5" debug="true" extdirs=""
+ destdir="${out.classes.absolute.dir}"
+ bootclasspathref="android.target.classpath"
+ verbose="${verbose}" classpath="${extensible.classpath}"
+ classpathref="android.libraries.jars">
+ <src path="${source.absolute.dir}" />
+ <src path="${gen.absolute.dir}" />
+ <src refid="android.libraries.src" />
+ <classpath>
+ <fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
+ <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
+ </classpath>
+ </javac>
+ </target>
+
+ <!-- empty default post-compile target. Create a similar target in
+ your build.xml and it'll be called instead of this one. -->
+ <target name="-post-compile"/>
+
+ <!-- Converts this project's .class files into .dex files -->
+ <target name="-dex" depends="compile, -post-compile">
+ <dex-helper />
+ </target>
+
+ <!-- Puts the project's resources into the output package file
+ This actually can create multiple resource package in case
+ Some custom apk with specific configuration have been
+ declared in default.properties.
+ -->
+ <target name="-package-resources">
+ <echo>Packaging resources</echo>
+ <aaptexec executable="${aapt}"
+ command="package"
+ versioncode="${version.code}"
+ manifest="AndroidManifest.xml"
+ assets="${asset.absolute.dir}"
+ androidjar="${android.jar}"
+ apkfolder="${out.absolute.dir}"
+ apkbasename="${ant.project.name}">
+ <res path="${resource.absolute.dir}" />
+ <!-- <nocompress /> forces no compression on any files in assets or res/raw -->
+ <!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw -->
+ </aaptexec>
+ </target>
+
+ <!-- Packages the application and sign it with a debug key. -->
+ <target name="-package-debug-sign" depends="-dex, -package-resources">
+ <package-helper sign.package="true" />
+ </target>
+
+ <!-- Packages the application without signing it. -->
+ <target name="-package-release" depends="-dex, -package-resources">
+ <package-helper sign.package="false" />
+ </target>
+
+ <target name="-compile-tested-if-test" if="tested.project.dir" unless="do.not.compile.again">
+ <subant target="compile">
+ <fileset dir="${tested.project.absolute.dir}" includes="build.xml" />
+ </subant>
+ </target>
+
+ <!-- Builds debug output package, provided all the necessary files are already dexed -->
+ <target name="debug" depends="-compile-tested-if-test, -package-debug-sign"
+ description="Builds the application and signs it with a debug key.">
+ <zipalign-helper in.package="${out.debug.unaligned.package}"
+ out.package="${out.debug.package}" />
+ <echo>Debug Package: ${out.debug.package}</echo>
+ </target>
+
+ <target name="-release-check">
+ <condition property="release.sign">
+ <and>
+ <isset property="key.store" />
+ <isset property="key.alias" />
+ </and>
+ </condition>
+ </target>
+
+ <target name="-release-nosign" depends="-release-check" unless="release.sign">
+ <echo>No key.store and key.alias properties found in build.properties.</echo>
+ <echo>Please sign ${out.unsigned.package} manually</echo>
+ <echo>and run zipalign from the Android SDK tools.</echo>
+ </target>
+
+ <target name="release" depends="-package-release, -release-nosign" if="release.sign"
+ description="Builds the application. The generated apk file must be signed before
+ it is published.">
+ <!-- Gets passwords -->
+ <input
+ message="Please enter keystore password (store:${key.store}):"
+ addproperty="key.store.password" />
+ <input
+ message="Please enter password for alias '${key.alias}':"
+ addproperty="key.alias.password" />
+
+ <!-- Signs the APK -->
+ <echo>Signing final apk...</echo>
+ <signjar
+ jar="${out.unsigned.package}"
+ signedjar="${out.unaligned.package}"
+ keystore="${key.store}"
+ storepass="${key.store.password}"
+ alias="${key.alias}"
+ keypass="${key.alias.password}"
+ verbose="${verbose}" />
+
+ <!-- Zip aligns the APK -->
+ <zipalign-helper in.package="${out.unaligned.package}"
+ out.package="${out.release.package}" />
+ <echo>Release Package: ${out.release.package}</echo>
+ </target>
+
+ <target name="install" depends="debug"
+ description="Installs/reinstalls the debug package onto a running
+ emulator or device. If the application was previously installed,
+ the signatures must match." >
+ <install-helper />
+ </target>
+
+ <target name="-uninstall-check">
+ <condition property="uninstall.run">
+ <isset property="manifest.package" />
+ </condition>
+ </target>
+
+ <target name="-uninstall-error" depends="-uninstall-check" unless="uninstall.run">
+ <echo>Unable to run 'ant uninstall', manifest.package property is not defined.
+ </echo>
+ </target>
+
+ <!-- Uninstalls the package from the default emulator/device -->
+ <target name="uninstall" depends="-uninstall-error" if="uninstall.run"
+ description="Uninstalls the application from a running emulator or device.">
+ <echo>Uninstalling ${manifest.package} from the default emulator or device...</echo>
+ <exec executable="${adb}" failonerror="true">
+ <arg line="${adb.device.arg}" />
+ <arg value="uninstall" />
+ <arg value="${manifest.package}" />
+ </exec>
+ </target>
+
+ <target name="clean" description="Removes output files created by other targets.">
+ <delete dir="${out.absolute.dir}" verbose="${verbose}" />
+ <delete dir="${gen.absolute.dir}" verbose="${verbose}" />
+ </target>
+
+ <!-- Targets for code-coverage measurement purposes, invoked from external file -->
+
+ <!-- Emma-instruments tested project classes (compiles the tested project if necessary)
+ and writes instrumented classes to ${instrumentation.absolute.dir}/classes -->
+ <target name="-emma-instrument" depends="compile">
+ <echo>Instrumenting classes from ${out.absolute.dir}/classes...</echo>
+ <!-- It only instruments class files, not any external libs -->
+ <emma enabled="true">
+ <instr verbosity="${verbosity}"
+ mode="overwrite"
+ instrpath="${out.absolute.dir}/classes"
+ outdir="${out.absolute.dir}/classes">
+ </instr>
+ <!-- TODO: exclusion filters on R*.class and allowing custom exclusion from
+ user defined file -->
+ </emma>
+ </target>
+
+ <target name="-dex-instrumented" depends="-emma-instrument">
+ <dex-helper>
+ <extra-parameters>
+ <arg value="--no-locals" />
+ </extra-parameters>
+ <external-libs>
+ <fileset file="${emma.dir}/emma_device.jar" />
+ </external-libs>
+ </dex-helper>
+ </target>
+
+ <!-- Invoked from external files for code coverage purposes -->
+ <target name="-package-with-emma" depends="-dex-instrumented, -package-resources">
+ <package-helper sign.package="true">
+ <extra-jars>
+ <!-- Injected from external file -->
+ <jarfile path="${emma.dir}/emma_device.jar" />
+ </extra-jars>
+ </package-helper>
+ </target>
+
+ <target name="-debug-with-emma" depends="-package-with-emma">
+ <zipalign-helper in.package="${out.debug.unaligned.package}"
+ out.package="${out.debug.package}" />
+ </target>
+
+ <target name="-install-with-emma" depends="-debug-with-emma">
+ <install-helper />
+ </target>
+
+ <!-- End of targets for code-coverage measurement purposes -->
+
+ <target name="help">
+ <!-- displays starts at col 13
+ |13 80| -->
+ <echo>Android Ant Build. Available targets:</echo>
+ <echo> help: Displays this help.</echo>
+ <echo> clean: Removes output files created by other targets.</echo>
+ <echo> compile: Compiles project's .java files into .class files.</echo>
+ <echo> debug: Builds the application and signs it with a debug key.</echo>
+ <echo> release: Builds the application. The generated apk file must be</echo>
+ <echo> signed before it is published.</echo>
+ <echo> install: Installs/reinstalls the debug package onto a running</echo>
+ <echo> emulator or device.</echo>
+ <echo> If the application was previously installed, the</echo>
+ <echo> signatures must match.</echo>
+ <echo> uninstall: Uninstalls the application from a running emulator or</echo>
+ <echo> device.</echo>
+ </target>
+</project>
diff --git a/files/ant_test_rules_r3.xml b/files/ant_test_rules_r3.xml
new file mode 100644
index 0000000..ffd7c41
--- /dev/null
+++ b/files/ant_test_rules_r3.xml
@@ -0,0 +1,459 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="android_rules" default="debug">
+
+ <!--
+ This rules file is meant to be imported by the custom Ant task:
+ com.android.ant.SetupTask
+
+ The following properties are put in place by the importing task:
+ android.jar, android.aidl, aapt, aidl, and dx
+
+ Additionnaly, the task sets up the following classpath reference:
+ android.target.classpath
+ This is used by the compiler task as the boot classpath.
+ -->
+
+ <!-- Custom tasks -->
+ <taskdef name="aaptexec"
+ classname="com.android.ant.AaptExecLoopTask"
+ classpathref="android.antlibs" />
+
+ <taskdef name="apkbuilder"
+ classname="com.android.ant.ApkBuilderTask"
+ classpathref="android.antlibs" />
+
+ <taskdef name="xpath"
+ classname="com.android.ant.XPathTask"
+ classpathref="android.antlibs" />
+
+ <!-- Properties -->
+
+ <!-- Tells adb which device to target. You can change this from the command line
+ by invoking "ant -Dadb.device.arg=-d" for device "ant -Dadb.device.arg=-e" for
+ the emulator. -->
+ <property name="adb.device.arg" value="" />
+
+ <property name="android.tools.dir" location="${sdk.dir}/tools" />
+ <!-- Name of the application package extracted from manifest file -->
+ <xpath input="AndroidManifest.xml" expression="/manifest/@package"
+ output="manifest.package" />
+ <!-- Value of the debuggable attribute (Application node) extracted from manifest file -->
+ <xpath input="AndroidManifest.xml" expression="/manifest/application/@android:debuggable"
+ output="manifest.debuggable" default="false"/>
+
+ <!-- Input directories -->
+ <property name="source.dir" value="src" />
+ <property name="source.absolute.dir" location="${source.dir}" />
+ <property name="gen.dir" value="gen" />
+ <property name="gen.absolute.dir" location="${gen.dir}" />
+ <property name="resource.dir" value="res" />
+ <property name="resource.absolute.dir" location="${resource.dir}" />
+ <property name="asset.dir" value="assets" />
+ <property name="asset.absolute.dir" location="${asset.dir}" />
+
+ <!-- Directory for the third party java libraries -->
+ <property name="external.libs.dir" value="libs" />
+ <property name="external.libs.absolute.dir" location="${external.libs.dir}" />
+
+ <!-- Directory for the native libraries -->
+ <property name="native.libs.dir" value="libs" />
+ <property name="native.libs.absolute.dir" location="${native.libs.dir}" />
+
+ <!-- Output directories -->
+ <property name="out.dir" value="bin" />
+ <property name="out.absolute.dir" location="${out.dir}" />
+ <property name="out.classes.dir" value="${out.absolute.dir}/classes" />
+ <property name="out.classes.absolute.dir" location="${out.classes.dir}" />
+
+ <!-- Intermediate files -->
+ <property name="dex.file.name" value="classes.dex" />
+ <property name="intermediate.dex.file" location="${out.absolute.dir}/${dex.file.name}" />
+
+ <!-- The final package file to generate -->
+ <property name="out.debug.unaligned.package"
+ location="${out.absolute.dir}/${ant.project.name}-debug-unaligned.apk" />
+ <property name="out.debug.package"
+ location="${out.absolute.dir}/${ant.project.name}-debug.apk" />
+ <property name="out.unsigned.package"
+ location="${out.absolute.dir}/${ant.project.name}-unsigned.apk" />
+ <property name="out.unaligned.package"
+ location="${out.absolute.dir}/${ant.project.name}-unaligned.apk" />
+ <property name="out.release.package"
+ location="${out.absolute.dir}/${ant.project.name}-release.apk" />
+
+ <!-- Verbosity -->
+ <property name="verbose" value="false" />
+ <!-- This is needed by emma as it uses multilevel verbosity instead of simple 'true' or 'false'
+ The property 'verbosity' is not user configurable and depends exclusively on 'verbose'
+ value.-->
+ <condition property="verbosity" value="verbose" else="quiet">
+ <istrue value="${verbose}" />
+ </condition>
+ <!-- This is needed to switch verbosity of zipalign. Depends exclusively on 'verbose'
+ -->
+ <condition property="v.option" value="-v" else="">
+ <istrue value="${verbose}" />
+ </condition>
+ <!-- This is needed to switch verbosity of dx. Depends exclusively on 'verbose' -->
+ <condition property="verbose.option" value="--verbose" else="">
+ <istrue value="${verbose}" />
+ </condition>
+
+ <!-- Tools -->
+ <condition property="exe" value=".exe" else=""><os family="windows" /></condition>
+ <property name="adb" location="${android.tools.dir}/adb${exe}" />
+ <property name="zipalign" location="${android.tools.dir}/zipalign${exe}" />
+
+ <!-- Emma configuration -->
+ <property name="emma.dir" value="${sdk.dir}/tools/lib" />
+ <path id="emma.lib">
+ <pathelement location="${emma.dir}/emma.jar" />
+ <pathelement location="${emma.dir}/emma_ant.jar" />
+ </path>
+ <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
+ <!-- End of emma configuration -->
+
+ <!-- Macros -->
+
+ <!-- Configurable macro, which allows to pass as parameters output directory,
+ output dex filename and external libraries to dex (optional) -->
+ <macrodef name="dex-helper">
+ <element name="external-libs" optional="yes" />
+ <element name="extra-parameters" optional="yes" />
+ <sequential>
+ <echo>Converting compiled files and external libraries into ${intermediate.dex.file}...</echo>
+ <apply executable="${dx}" failonerror="true" parallel="true">
+ <arg value="--dex" />
+ <arg value="--output=${intermediate.dex.file}" />
+ <extra-parameters />
+ <arg line="${verbose.option}" />
+ <arg path="${out.classes.absolute.dir}" />
+ <fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
+ <path refid="android.libraries.jars" />
+ <external-libs />
+ </apply>
+ </sequential>
+ </macrodef>
+
+ <!-- This is macro that enable passing variable list of external jar files to ApkBuilder
+ Example of use:
+ <package-helper sign.package="true">
+ <extra-jars>
+ <jarfolder path="my_jars" />
+ <jarfile path="foo/bar.jar" />
+ <jarfolder path="your_jars" />
+ </extra-jars>
+ </package-helper> -->
+ <macrodef name="package-helper">
+ <attribute name="sign.package" />
+ <element name="extra-jars" optional="yes" />
+ <sequential>
+ <apkbuilder
+ outfolder="${out.absolute.dir}"
+ basename="${ant.project.name}"
+ signed="@{sign.package}"
+ debug="${manifest.debuggable}"
+ verbose="${verbose}">
+ <file path="${intermediate.dex.file}" />
+ <sourcefolder path="${source.absolute.dir}" />
+ <sourcefolder refid="android.libraries.src" />
+ <jarfolder path="${external.libs.absolute.dir}" />
+ <jarfolder refid="android.libraries.libs" />
+ <nativefolder path="${native.libs.absolute.dir}" />
+ <nativefolder refid="android.libraries.libs" />
+ <extra-jars/>
+ </apkbuilder>
+ </sequential>
+ </macrodef>
+
+ <!-- This is macro which zipaligns in.package and outputs it to out.package. Used by targets
+ debug, -debug-with-emma and release.-->
+ <macrodef name="zipalign-helper">
+ <attribute name="in.package" />
+ <attribute name="out.package" />
+ <sequential>
+ <echo>Running zip align on final apk...</echo>
+ <exec executable="${zipalign}" failonerror="true">
+ <arg line="${v.option}" />
+ <arg value="-f" />
+ <arg value="4" />
+ <arg path="@{in.package}" />
+ <arg path="@{out.package}" />
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <!-- This is macro used only for sharing code among two targets, -install and
+ -install-with-emma which do exactly the same but differ in dependencies -->
+ <macrodef name="install-helper">
+ <sequential>
+ <echo>Installing ${out.debug.package} onto default emulator or device...</echo>
+ <exec executable="${adb}" failonerror="true">
+ <arg line="${adb.device.arg}" />
+ <arg value="install" />
+ <arg value="-r" />
+ <arg path="${out.debug.package}" />
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <!-- Rules -->
+
+ <!-- Creates the output directories if they don't exist yet. -->
+ <target name="-dirs">
+ <echo>Creating output directories if needed...</echo>
+ <mkdir dir="${resource.absolute.dir}" />
+ <mkdir dir="${external.libs.absolute.dir}" />
+ <mkdir dir="${gen.absolute.dir}" />
+ <mkdir dir="${out.absolute.dir}" />
+ <mkdir dir="${out.classes.absolute.dir}" />
+ </target>
+
+ <!-- Generates the R.java file for this project's resources. -->
+ <target name="-resource-src" depends="-dirs">
+ <echo>Generating R.java / Manifest.java from the resources...</echo>
+ <aaptexec executable="${aapt}"
+ command="package"
+ verbose="${verbose}"
+ manifest="AndroidManifest.xml"
+ androidjar="${android.jar}"
+ rfolder="${gen.absolute.dir}">
+ <res path="${resource.absolute.dir}" />
+ </aaptexec>
+ </target>
+
+ <!-- Generates java classes from .aidl files. -->
+ <target name="-aidl" depends="-dirs">
+ <echo>Compiling aidl files into Java classes...</echo>
+ <apply executable="${aidl}" failonerror="true">
+ <arg value="-p${android.aidl}" />
+ <arg value="-I${source.absolute.dir}" />
+ <arg value="-o${gen.absolute.dir}" />
+ <fileset dir="${source.absolute.dir}">
+ <include name="**/*.aidl" />
+ </fileset>
+ </apply>
+ </target>
+
+ <!-- Compiles this project's .java files into .class files. -->
+ <target name="compile" depends="-resource-src, -aidl"
+ description="Compiles project's .java files into .class files">
+ <!-- If android rules are used for a test project, its classpath should include
+ tested project's location -->
+ <condition property="extensible.classpath"
+ value="${tested.project.absolute.dir}/bin/classes" else=".">
+ <isset property="tested.project.absolute.dir" />
+ </condition>
+ <condition property="extensible.libs.classpath"
+ value="${tested.project.absolute.dir}/libs" else="./libs">
+ <isset property="tested.project.absolute.dir" />
+ </condition>
+ <javac encoding="ascii" target="1.5" debug="true" extdirs=""
+ destdir="${out.classes.absolute.dir}"
+ bootclasspathref="android.target.classpath"
+ verbose="${verbose}" classpath="${extensible.classpath}"
+ classpathref="android.libraries.jars">
+ <src path="${source.absolute.dir}" />
+ <src path="${gen.absolute.dir}" />
+ <src refid="android.libraries.src" />
+ <classpath>
+ <fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
+ <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
+ </classpath>
+ </javac>
+ </target>
+
+ <!-- Converts this project's .class files into .dex files -->
+ <target name="-dex" depends="compile">
+ <dex-helper />
+ </target>
+
+ <!-- Puts the project's resources into the output package file
+ This actually can create multiple resource package in case
+ Some custom apk with specific configuration have been
+ declared in default.properties.
+ -->
+ <target name="-package-resources">
+ <echo>Packaging resources</echo>
+ <aaptexec executable="${aapt}"
+ command="package"
+ manifest="AndroidManifest.xml"
+ assets="${asset.absolute.dir}"
+ androidjar="${android.jar}"
+ apkfolder="${out.absolute.dir}"
+ apkbasename="${ant.project.name}">
+ <res path="${resource.absolute.dir}" />
+ <!-- <nocompress /> forces no compression on any files in assets or res/raw -->
+ <!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw -->
+ </aaptexec>
+ </target>
+
+ <!-- Packages the application and sign it with a debug key. -->
+ <target name="-package-debug-sign" depends="-dex, -package-resources">
+ <package-helper sign.package="true" />
+ </target>
+
+ <!-- Packages the application without signing it. -->
+ <target name="-package-release" depends="-dex, -package-resources">
+ <package-helper sign.package="false" />
+ </target>
+
+ <target name="-compile-tested-if-test" if="tested.project.dir" unless="do.not.compile.again">
+ <subant target="compile">
+ <fileset dir="${tested.project.absolute.dir}" includes="build.xml" />
+ </subant>
+ </target>
+
+ <!-- Builds debug output package, provided all the necessary files are already dexed -->
+ <target name="debug" depends="-compile-tested-if-test, -package-debug-sign"
+ description="Builds the application and signs it with a debug key.">
+ <zipalign-helper in.package="${out.debug.unaligned.package}"
+ out.package="${out.debug.package}" />
+ <echo>Debug Package: ${out.debug.package}</echo>
+ </target>
+
+ <target name="-release-check">
+ <condition property="release.sign">
+ <and>
+ <isset property="key.store" />
+ <isset property="key.alias" />
+ </and>
+ </condition>
+ </target>
+
+ <target name="-release-nosign" depends="-release-check" unless="release.sign">
+ <echo>No key.store and key.alias properties found in build.properties.</echo>
+ <echo>Please sign ${out.unsigned.package} manually</echo>
+ <echo>and run zipalign from the Android SDK tools.</echo>
+ </target>
+
+ <target name="release" depends="-package-release, -release-nosign" if="release.sign"
+ description="Builds the application. The generated apk file must be signed before
+ it is published.">
+ <!-- Gets passwords -->
+ <input
+ message="Please enter keystore password (store:${key.store}):"
+ addproperty="key.store.password" />
+ <input
+ message="Please enter password for alias '${key.alias}':"
+ addproperty="key.alias.password" />
+
+ <!-- Signs the APK -->
+ <echo>Signing final apk...</echo>
+ <signjar
+ jar="${out.unsigned.package}"
+ signedjar="${out.unaligned.package}"
+ keystore="${key.store}"
+ storepass="${key.store.password}"
+ alias="${key.alias}"
+ keypass="${key.alias.password}"
+ verbose="${verbose}" />
+
+ <!-- Zip aligns the APK -->
+ <zipalign-helper in.package="${out.unaligned.package}"
+ out.package="${out.release.package}" />
+ <echo>Release Package: ${out.release.package}</echo>
+ </target>
+
+ <target name="install" depends="debug"
+ description="Installs/reinstalls the debug package onto a running
+ emulator or device. If the application was previously installed,
+ the signatures must match." >
+ <install-helper />
+ </target>
+
+ <target name="-uninstall-check">
+ <condition property="uninstall.run">
+ <isset property="manifest.package" />
+ </condition>
+ </target>
+
+ <target name="-uninstall-error" depends="-uninstall-check" unless="uninstall.run">
+ <echo>Unable to run 'ant uninstall', manifest.package property is not defined.
+ </echo>
+ </target>
+
+ <!-- Uninstalls the package from the default emulator/device -->
+ <target name="uninstall" depends="-uninstall-error" if="uninstall.run"
+ description="Uninstalls the application from a running emulator or device.">
+ <echo>Uninstalling ${manifest.package} from the default emulator or device...</echo>
+ <exec executable="${adb}" failonerror="true">
+ <arg line="${adb.device.arg}" />
+ <arg value="uninstall" />
+ <arg value="${manifest.package}" />
+ </exec>
+ </target>
+
+ <target name="clean" description="Removes output files created by other targets.">
+ <delete dir="${out.absolute.dir}" verbose="${verbose}" />
+ <delete dir="${gen.absolute.dir}" verbose="${verbose}" />
+ </target>
+
+ <!-- Targets for code-coverage measurement purposes, invoked from external file -->
+
+ <!-- Emma-instruments tested project classes (compiles the tested project if necessary)
+ and writes instrumented classes to ${instrumentation.absolute.dir}/classes -->
+ <target name="-emma-instrument" depends="compile">
+ <echo>Instrumenting classes from ${out.absolute.dir}/classes...</echo>
+ <!-- It only instruments class files, not any external libs -->
+ <emma enabled="true">
+ <instr verbosity="${verbosity}"
+ mode="overwrite"
+ instrpath="${out.absolute.dir}/classes"
+ outdir="${out.absolute.dir}/classes">
+ </instr>
+ <!-- TODO: exclusion filters on R*.class and allowing custom exclusion from
+ user defined file -->
+ </emma>
+ </target>
+
+ <target name="-dex-instrumented" depends="-emma-instrument">
+ <dex-helper>
+ <extra-parameters>
+ <arg value="--no-locals" />
+ </extra-parameters>
+ <external-libs>
+ <fileset file="${emma.dir}/emma_device.jar" />
+ </external-libs>
+ </dex-helper>
+ </target>
+
+ <!-- Invoked from external files for code coverage purposes -->
+ <target name="-package-with-emma" depends="-dex-instrumented, -package-resources">
+ <package-helper sign.package="true">
+ <extra-jars>
+ <!-- Injected from external file -->
+ <jarfile path="${emma.dir}/emma_device.jar" />
+ </extra-jars>
+ </package-helper>
+ </target>
+
+ <target name="-debug-with-emma" depends="-package-with-emma">
+ <zipalign-helper in.package="${out.debug.unaligned.package}"
+ out.package="${out.debug.package}" />
+ </target>
+
+ <target name="-install-with-emma" depends="-debug-with-emma">
+ <install-helper />
+ </target>
+
+ <!-- End of targets for code-coverage measurement purposes -->
+
+ <target name="help">
+ <!-- displays starts at col 13
+ |13 80| -->
+ <echo>Android Ant Build. Available targets:</echo>
+ <echo> help: Displays this help.</echo>
+ <echo> clean: Removes output files created by other targets.</echo>
+ <echo> compile: Compiles project's .java files into .class files.</echo>
+ <echo> debug: Builds the application and signs it with a debug key.</echo>
+ <echo> release: Builds the application. The generated apk file must be</echo>
+ <echo> signed before it is published.</echo>
+ <echo> install: Installs/reinstalls the debug package onto a running</echo>
+ <echo> emulator or device.</echo>
+ <echo> If the application was previously installed, the</echo>
+ <echo> signatures must match.</echo>
+ <echo> uninstall: Uninstalls the application from a running emulator or</echo>
+ <echo> device.</echo>
+ </target>
+</project>
diff --git a/files/sdk.properties b/files/sdk.properties
index a48a85d..cf62029 100644
--- a/files/sdk.properties
+++ b/files/sdk.properties
@@ -1,4 +1,6 @@
# SDK properties
+# This file is copied in the root folder of each platform component.
+# If it used by various tools to figure out what the platform can do.
sdk.build.support.library=true
-sdk.ant.build.revision=2
+sdk.ant.build.revision=3
sdk.ant.templates.revision=1 \ No newline at end of file
diff --git a/sdklauncher/sdklauncher.c b/sdklauncher/sdklauncher.c
index 23b785d..e1d97a1 100644
--- a/sdklauncher/sdklauncher.c
+++ b/sdklauncher/sdklauncher.c
@@ -29,9 +29,24 @@
#ifdef _WIN32
#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
#include <windows.h>
+int _enable_dprintf = 0;
+
+void dprintf(char *msg, ...) {
+ va_list ap;
+ va_start(ap, msg);
+
+ if (_enable_dprintf) {
+ vfprintf(stderr, msg, ap);
+ }
+
+ va_end(ap);
+}
+
void display_error(LPSTR description) {
DWORD err = GetLastError();
LPSTR s, s2;
@@ -170,8 +185,8 @@ int sdk_launcher() {
int result = 0;
STARTUPINFO startup;
PROCESS_INFORMATION pinfo;
- CHAR program_path[MAX_PATH];
- int ret;
+ CHAR program_dir[MAX_PATH];
+ int ret, pos;
CHAR temp_filename[MAX_PATH];
HANDLE temp_handle;
@@ -189,29 +204,50 @@ int sdk_launcher() {
startup.hStdOutput = temp_handle;
startup.hStdError = temp_handle;
- /* get path of current program */
- GetModuleFileName(NULL, program_path, sizeof(program_path));
-
- ret = CreateProcess(
- NULL, /* program path */
- "tools\\android.bat update sdk", /* command-line */
- NULL, /* process handle is not inheritable */
- NULL, /* thread handle is not inheritable */
- TRUE, /* yes, inherit some handles */
- CREATE_NO_WINDOW, /* we don't want a console */
- NULL, /* use parent's environment block */
- NULL, /* use parent's starting directory */
- &startup, /* startup info, i.e. std handles */
- &pinfo);
-
- if (!ret) {
- display_error("Failed to execute tools\\android.bat:");
+ /* get path of current program, to switch dirs here when executing the command. */
+ ret = GetModuleFileName(NULL, program_dir, sizeof(program_dir));
+ if (ret == 0) {
+ display_error("Failed to get program's filename:");
result = 1;
} else {
- WaitForSingleObject(pinfo.hProcess, INFINITE);
- CloseHandle(pinfo.hProcess);
- CloseHandle(pinfo.hThread);
+ /* Remove the last segment to keep only the directory. */
+ pos = ret - 1;
+ while (pos > 0 && program_dir[pos] != '\\') {
+ --pos;
+ }
+ program_dir[pos] = 0;
+ }
+
+ if (!result) {
+ dprintf("Program dir: %s\n", program_dir);
+
+ ret = CreateProcess(
+ NULL, /* program path */
+ "tools\\android.bat update sdk", /* command-line */
+ NULL, /* process handle is not inheritable */
+ NULL, /* thread handle is not inheritable */
+ TRUE, /* yes, inherit some handles */
+ CREATE_NO_WINDOW, /* we don't want a console */
+ NULL, /* use parent's environment block */
+ program_dir, /* use parent's starting directory */
+ &startup, /* startup info, i.e. std handles */
+ &pinfo);
+
+ dprintf("CreateProcess returned %d\n", ret);
+
+ if (!ret) {
+ display_error("Failed to execute tools\\android.bat:");
+ result = 1;
+ } else {
+ dprintf("Wait for process to finish.\n");
+
+ WaitForSingleObject(pinfo.hProcess, INFINITE);
+ CloseHandle(pinfo.hProcess);
+ CloseHandle(pinfo.hThread);
+ }
}
+
+ dprintf("Cleanup.\n");
if (!CloseHandle(temp_handle)) {
display_error("CloseHandle temp file failed");
@@ -229,6 +265,9 @@ int sdk_launcher() {
}
int main(int argc, char **argv) {
+ _enable_dprintf = argc > 1 && strcmp(argv[1], "-v") == 0;
+ dprintf("Verbose debug mode.\n");
+
return sdk_launcher();
}
diff --git a/sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java b/sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java
index ab105ec..6536baa 100644
--- a/sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java
+++ b/sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java
@@ -115,7 +115,7 @@ class CommandLineProcessor {
"Silent mode: only errors are printed out.",
false);
define(Mode.BOOLEAN, false, GLOBAL_FLAG_VERB, NO_VERB_OBJECT, "h", KEY_HELP,
- "This help.",
+ "Help on a specific command.",
false);
}
@@ -229,7 +229,7 @@ class CommandLineProcessor {
* @param args The arguments typically received by a main method.
*/
public void parseArgs(String[] args) {
- String needsHelp = null;
+ String errorMsg = null;
String verb = null;
String directObject = null;
@@ -252,7 +252,7 @@ class CommandLineProcessor {
// It looks like a dashed parameter and we don't have a a verb/object
// set yet, the parameter was just given too early.
- needsHelp = String.format(
+ errorMsg = String.format(
"Flag '%1$s' is not a valid global flag. Did you mean to specify it after the verb/object name?",
a);
return;
@@ -260,7 +260,7 @@ class CommandLineProcessor {
// It looks like a dashed parameter and but it is unknown by this
// verb-object combination
- needsHelp = String.format(
+ errorMsg = String.format(
"Flag '%1$s' is not valid for '%2$s %3$s'.",
a, verb, directObject);
return;
@@ -278,7 +278,7 @@ class CommandLineProcessor {
// Error if it was not a valid verb
if (verb == null) {
- needsHelp = String.format(
+ errorMsg = String.format(
"Expected verb after global parameters but found '%1$s' instead.",
a);
return;
@@ -303,7 +303,7 @@ class CommandLineProcessor {
// Error if it was not a valid object for that verb
if (directObject == null) {
- needsHelp = String.format(
+ errorMsg = String.format(
"Expected verb after global parameters but found '%1$s' instead.",
a);
return;
@@ -318,7 +318,7 @@ class CommandLineProcessor {
String error = null;
if (arg.getMode().needsExtra()) {
if (++i >= n) {
- needsHelp = String.format("Missing argument for flag %1$s.", a);
+ errorMsg = String.format("Missing argument for flag %1$s.", a);
return;
}
@@ -326,27 +326,26 @@ class CommandLineProcessor {
} else {
error = arg.getMode().process(arg, null);
- // If we just toggled help, we want to exit now without printing any error.
- // We do this test here only when a Boolean flag is toggled since booleans
- // are the only flags that don't take parameters and help is a boolean.
if (isHelpRequested()) {
- printHelpAndExit(null);
- // The call above should terminate however in unit tests we override
- // it so we still need to return here.
- return;
+ // The --help flag was requested. We'll continue the usual processing
+ // so that we can find the optional verb/object words. Those will be
+ // used to print specific help.
+ // Setting a non-null error message triggers printing the help, however
+ // there is no specific error to print.
+ errorMsg = "";
}
}
if (error != null) {
- needsHelp = String.format("Invalid usage for flag %1$s: %2$s.", a, error);
+ errorMsg = String.format("Invalid usage for flag %1$s: %2$s.", a, error);
return;
}
}
}
- if (needsHelp == null) {
+ if (errorMsg == null) {
if (verb == null && !acceptLackOfVerb()) {
- needsHelp = "Missing verb name.";
+ errorMsg = "Missing verb name.";
} else if (verb != null) {
if (directObject == null) {
// Make sure this verb has an optional direct object
@@ -359,7 +358,7 @@ class CommandLineProcessor {
}
if (directObject == null) {
- needsHelp = String.format("Missing object name for verb '%1$s'.", verb);
+ errorMsg = String.format("Missing object name for verb '%1$s'.", verb);
return;
}
}
@@ -383,7 +382,7 @@ class CommandLineProcessor {
}
if (missing != null) {
- needsHelp = String.format(
+ errorMsg = String.format(
"The %1$s %2$s must be defined for action '%3$s %4$s'",
plural ? "parameters" : "parameter",
missing,
@@ -396,8 +395,8 @@ class CommandLineProcessor {
}
}
} finally {
- if (needsHelp != null) {
- printHelpAndExitForAction(verb, directObject, needsHelp);
+ if (errorMsg != null) {
+ printHelpAndExitForAction(verb, directObject, errorMsg);
}
}
}
@@ -464,7 +463,7 @@ class CommandLineProcessor {
*/
public void printHelpAndExitForAction(String verb, String directObject,
String errorFormat, Object... args) {
- if (errorFormat != null) {
+ if (errorFormat != null && errorFormat.length() > 0) {
stderr(errorFormat, args);
}
@@ -474,31 +473,37 @@ class CommandLineProcessor {
*/
stdout("\n" +
"Usage:\n" +
- " android [global options] action [action options]\n" +
+ " android [global options] %s [action options]\n" +
"\n" +
- "Global options:");
+ "Global options:",
+ verb == null ? "action" :
+ verb + (directObject == null ? "" : " " + directObject));
listOptions(GLOBAL_FLAG_VERB, NO_VERB_OBJECT);
if (verb == null || directObject == null) {
stdout("\nValid actions are composed of a verb and an optional direct object:");
for (String[] action : mActions) {
-
- stdout("- %1$6s %2$-12s: %3$s",
- action[ACTION_VERB_INDEX],
- action[ACTION_OBJECT_INDEX],
- action[ACTION_DESC_INDEX]);
+ if (verb == null || verb.equals(action[ACTION_VERB_INDEX])) {
+ stdout("- %1$6s %2$-12s: %3$s",
+ action[ACTION_VERB_INDEX],
+ action[ACTION_OBJECT_INDEX],
+ action[ACTION_DESC_INDEX]);
+ }
}
}
- for (String[] action : mActions) {
- if (verb == null || verb.equals(action[ACTION_VERB_INDEX])) {
- if (directObject == null || directObject.equals(action[ACTION_OBJECT_INDEX])) {
- stdout("\nAction \"%1$s %2$s\":",
- action[ACTION_VERB_INDEX],
- action[ACTION_OBJECT_INDEX]);
- stdout(" %1$s", action[ACTION_DESC_INDEX]);
- stdout("Options:");
- listOptions(action[ACTION_VERB_INDEX], action[ACTION_OBJECT_INDEX]);
+ // Only print details if a verb/object is requested
+ if (verb != null) {
+ for (String[] action : mActions) {
+ if (verb == null || verb.equals(action[ACTION_VERB_INDEX])) {
+ if (directObject == null || directObject.equals(action[ACTION_OBJECT_INDEX])) {
+ stdout("\nAction \"%1$s %2$s\":",
+ action[ACTION_VERB_INDEX],
+ action[ACTION_OBJECT_INDEX]);
+ stdout(" %1$s", action[ACTION_DESC_INDEX]);
+ stdout("Options:");
+ listOptions(action[ACTION_VERB_INDEX], action[ACTION_OBJECT_INDEX]);
+ }
}
}
}
diff --git a/sdkmanager/app/src/com/android/sdkmanager/Main.java b/sdkmanager/app/src/com/android/sdkmanager/Main.java
index 58a9a98..49eee7e 100644
--- a/sdkmanager/app/src/com/android/sdkmanager/Main.java
+++ b/sdkmanager/app/src/com/android/sdkmanager/Main.java
@@ -232,6 +232,10 @@ public class Main {
updateTestProject();
} else if (SdkCommandLine.OBJECT_LIB_PROJECT.equals(directObject)) {
updateProject(true /*library*/);
+ } else if (SdkCommandLine.OBJECT_SDK.equals(directObject)) {
+ showMainWindow(true /*autoUpdate*/);
+ } else if (SdkCommandLine.OBJECT_ADB.equals(directObject)) {
+ updateAdb();
}
} else if (SdkCommandLine.VERB_DELETE.equals(verb) &&
SdkCommandLine.OBJECT_AVD.equals(directObject)) {
@@ -244,14 +248,6 @@ public class Main {
} else if (verb == null && directObject == null) {
showMainWindow(false /*autoUpdate*/);
- } else if (SdkCommandLine.VERB_UPDATE.equals(verb) &&
- SdkCommandLine.OBJECT_SDK.equals(directObject)) {
- showMainWindow(true /*autoUpdate*/);
-
- } else if (SdkCommandLine.VERB_UPDATE.equals(verb) &&
- SdkCommandLine.OBJECT_ADB.equals(directObject)) {
- updateAdb();
-
} else {
mSdkCommandLine.printHelpAndExit(null);
}
diff --git a/templates/build.template b/templates/build.template
index 3959c57..549ce7c 100644
--- a/templates/build.template
+++ b/templates/build.template
@@ -1,40 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="PROJECT_NAME" default="help">
- <!-- The local.properties file is created and updated by the 'android' tool.
- It contains the path to the SDK. It should *NOT* be checked in in Version
- Control Systems. -->
+<!-- The local.properties file is created and updated by the 'android'
+ tool.
+ It contains the path to the SDK. It should *NOT* be checked in in
+ Version Control Systems. -->
<property file="local.properties" />
<!-- The build.properties file can be created by you and is never touched
- by the 'android' tool. This is the place to change some of the default property values
- used by the Ant rules.
+ by the 'android' tool. This is the place to change some of the
+ default property values used by the Ant rules.
Here are some properties you may want to change/update:
application.package
- the name of your application package as defined in the manifest. Used by the
- 'uninstall' rule.
+ The name of your application package as defined in the manifest.
+ Used by the 'uninstall' rule.
source.dir
- the name of the source directory. Default is 'src'.
+ The name of the source directory. Default is 'src'.
out.dir
- the name of the output directory. Default is 'bin'.
+ The name of the output directory. Default is 'bin'.
- Properties related to the SDK location or the project target should be updated
- using the 'android' tool with the 'update' action.
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
- This file is an integral part of the build system for your application and
- should be checked in in Version Control Systems.
+ This file is an integral part of the build system for your
+ application and should be checked in in Version Control Systems.
-->
<property file="build.properties" />
- <!-- The default.properties file is created and updated by the 'android' tool, as well
- as ADT.
- This file is an integral part of the build system for your application and
- should be checked in in Version Control Systems. -->
+ <!-- The default.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+ This file is an integral part of the build system for your
+ application and should be checked in in Version Control Systems. -->
<property file="default.properties" />
- <!-- Custom Android task to deal with the project target, and import the proper rules.
+ <!-- Custom Android task to deal with the project target, and import the
+ proper rules.
This requires ant 1.6.0 or above. -->
<path id="android.antlibs">
<pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
@@ -48,19 +50,35 @@
classname="com.android.ant.SetupTask"
classpathref="android.antlibs" />
- <!-- Execute the Android Setup task that will setup some properties specific to the target,
- and import the build rules files.
+<!-- extension targets. Uncomment the ones where you want to do custom work
+ in between standard targets -->
+<!--
+ <target name="-pre-build">
+ </target>
+ <target name="-pre-compile">
+ </target>
+ <target name="-post-compile">
+ </target>
+-->
- The rules file is imported from
- <SDK>/platforms/<target_platform>/templates/android_rules.xml
- To customize some build steps for your project:
- - copy the content of the main node <project> from android_rules.xml
- - paste it in this build.xml below the <setup /> task.
- - disable the import by changing the setup task below to <setup import="false" />
+ <!-- Execute the Android Setup task that will setup some properties
+ specific to the target, and import the build rules files.
+
+ The rules file is imported from
+ <SDK>/platforms/<target_platform>/ant/ant_rules_r#.xml
- This will ensure that the properties are setup correctly but that your customized
- build steps are used.
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <setup> task.
+ - customize it to your needs.
+ - Customize the whole script.
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, *after* the <setup> task
+ - disable the import of the rules by changing the setup task
+ below to <setup import="false" />.
+ - customize to your needs.
-->
<setup />