Skip to content

Instantly share code, notes, and snippets.

@tuoxie007
Last active February 26, 2018 06:35
Show Gist options
  • Save tuoxie007/9183147 to your computer and use it in GitHub Desktop.
Save tuoxie007/9183147 to your computer and use it in GitHub Desktop.
android debug from cli
#!/bin/bash
package=<Your Package>
appname=<Your App Name>
level=0
if [ "$1" == "build" ]; then
level=0
if [ "$2" == "java" ]; then
level=1
fi
elif [ "$1" == "install" ]; then
level=2
elif [ "$1" == "start" ]; then
level=3
fi
if [ "$level" -le "0" ]; then
echo "Build JNI Application"
cd jni/
ndk-build >/dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "ndk-build failed"
exit 1
fi
cd -
fi
if [ "$level" -le "1" ]; then
echo "Build Application"
ant debug >/dev/null
fi
if [ "$level" -le "2" ]; then
echo "Install Application"
adb uninstall $package >/dev/null
adb install bin/$appname-debug.apk >/dev/null 2>&1
fi
if [ "$level" -le "3" ]; then
echo "Start Application"
adb shell am force-stop $package
adb logcat -c
adb shell am start -n $package/$package.MainActivity >/dev/null
#adb logcat | grep `adb shell ps | grep $package | cut -c10-15`
adb logcat -s "recorder"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment