Created
May 17, 2013 00:42
-
-
Save ruel/5596228 to your computer and use it in GitHub Desktop.
Script for building and running APK in android command line.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Version: 051613001 | |
# This is used for debugging APKs. This command should be ran in the root directory of the project | |
# The name of the apk file is < ProjectName >-debug.apk and inside the bin directory | |
# Firstly, run ant debug | |
ant debug | |
# Get the project name and instantiate the apk file path | |
pname=$( pwd | awk -F/ '{ print $NF }' ) | |
apk=bin/$pname-debug.apk | |
# Get the package name from AndroidManifest.xml | |
pack=$( cat AndroidManifest.xml | grep package | awk -F\" '{ print $2 }' ) | |
# Get the first occurrence of the Activity | |
act=$( cat AndroidManifest.xml | grep 'activity android:name' | awk -F\" '{ print $2 }' | head -1 ) | |
# Make sure the execution was successful first | |
if [ $? -eq 0 ]; then | |
# Check for the APK in bin directory | |
if [ -f $apk ]; then | |
# If found, install the file | |
adb -d install -r $apk | |
# Run the apk inside the application | |
adb shell am start -n $pack/$pack.$act | |
# Filter logcat to show the App's logs | |
adb logcat ActivityManager:I $pname:D *:S | |
else | |
echo "[ERR] "APK $apk does not exist. > /dev/stderr | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment