setenv: warn that the script is meant to be sourced, not executed
[android/android-app-development-getting-started.git] / compile_and_run_app.sh
1 #!/bin/sh
2
3 set -e
4
5 if command -v xmllint >/dev/null 2>&1;
6 then
7   # Try xmllint from the "xmllint" package
8   XPATH="xmllint --xpath "
9 elif command -v xpath >/dev/null 2>&1;
10 then
11   # xpath is from the perl XML::XPath module: libxml-xpath-perl package
12   XPATH="xpath -e"
13 else
14   { echo "Install either xmllint or the XML::XPath perl module" 1>&2; exit 1; }
15 fi
16
17 APP_NAME=$($XPATH "string(//project/@name)" build.xml)
18 PACKAGE=$($XPATH "string(//manifest/@package)" AndroidManifest.xml)
19 MAIN_ACTIVITY=$($XPATH "string(//activity[1]/@*[local-name() = 'name'])" AndroidManifest.xml)
20
21 ant debug
22 adb -s emulator-5554 install -r bin/${APP_NAME}-debug.apk
23 adb -s emulator-5554 -e shell am start -a android.intent.action.MAIN -n ${PACKAGE}/${PACKAGE}.${MAIN_ACTIVITY}