Android and CLI
Yesterday our training involved Android together with the command line interface. There’s not much chat, but overall, I can say that IDEs are optional. Really, I’m considering using command line on (almost) all my development environments.
I’ve learned android over a year ago, and it was just yesterday when I learned how compilation on android works (or at least the basic level). The most important thing I’ve learned yesterday is, command line should be for beginners. But in most points, command line is perfect on all levels. In beginners’ context, they can understand how things really work. IDEs hide most key parts in building, compilation, and interpretation. And in the professional context, command line gives complete control to the developer.
Thing is, it just sank into my brains.
Surely when a developer gets used to IDEs, he/she will be dependent on auto-complete, intellisense, error highlights, auto-debugs, etc. And when you take away those tools (hence IDEs) from that developer, without behind-the-scenes knowledge, he/she will be useless.
– Markku (Our finnish training instructor)
That’s all for this rant about IDEs and CLI. For my parting, here’s the script I wrote yesterday for CLI android building. (Credit goes to the training about Linux and scripting last week)
#!/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
For today, we’ll deal with bloody Objective-C.



