YrXtals/scripts/android/debug.sh

31 lines
955 B
Bash
Executable File

#!/usr/bin/env bash
# installs the apk, launches the activity, and tails logcat filtered to YrXtals and native crash channels.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/_env.sh"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
"$SCRIPT_DIR/install.sh" release-debug
if [[ -z "${ANDROID_TARGET:-}" ]]; then
echo "no device selected." >&2
exit 2
fi
PKG="org.elseif.yrxtals"
adb -s "$ANDROID_TARGET" logcat -c || true
adb -s "$ANDROID_TARGET" shell am start -n "$PKG/.MainActivity" >/dev/null
PID="$(adb -s "$ANDROID_TARGET" shell pidof "$PKG" | tr -d '\r')"
echo "running pid=$PID on $ANDROID_TARGET — tailing logcat (Ctrl+C to stop)"
if [[ -n "$PID" ]]; then
exec adb -s "$ANDROID_TARGET" logcat --pid="$PID" YrXtals:V yr_crystals:V AndroidRuntime:E libc:F DEBUG:F '*:S'
else
exec adb -s "$ANDROID_TARGET" logcat YrXtals:V yr_crystals:V AndroidRuntime:E libc:F DEBUG:F '*:S'
fi