Android Development Tips ...

Note:
    All tips/commands are written w.r.t Linux(Ubuntu) OS ...

1. Command to start Android AVD manager from commandline

    $ android avd

2. Command to start Android SDK manager from commandline

    $ android sdk

3. An android emulator device is always rooted. Remount /system partition on the device

    $ adb remount
    (or)
    $ adb shell 
    # mount -o rw,remount /system

note:
    Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device. 

4. To avoid the Out of memory error when trying to copy the any file from host to device(guest) /system/bin, you need to start the emulator manually with a large –partion-size argument:

    $ emulator -avd MYNAME -partition-size 300

5. Android Development Tools on host OS(Linux, Windows)

    $ monitor => device monitor ( logcat, file_manager, push, pull)

    $ lint => static analysis

    $ proguard => code obfuscation (makes difficult to reverse engineer)

    $ monkey => gui testing tool

6. Build android ANT projects

    $ ant debug => debug build & create ,apk file
       (This creates your debug .apk file inside the project bin/ directory, named -debug.apk)

    $ ant release => release build & create ,apk file

    $ ant debug install => debug build & create .apk file and install in the active AVD device

7. Install .apk file on the AVD

    $ adb install .apk

    $ adb -s emulator-5554 install path/to/your/app.apk

    $ adb -d install path/to/your/app.apk
      (note: The -d flag specifies that you want to use the attached device (in case you also have an emulator running)

8. ADB commands

To know the android device API version => 
    $ adb shell getprop ro.build.version.release

To start a application from commandline => 
    $ adb shell am start -n com.google.android.contacts/.ContactsActivity

To terminate the application => 
    $ adb shell am kill com.google.android.contacts
    $ adb shell am force-stop com.google.android.contacts

To start the android Service => 
    $ adb shell am startservice -n packageName/.ServiceClass

9. Debug native code on the emulator (or) device using gdbclient(host), gdbserver(device)

a. First you need to run gdbserver on the device =>

    $ gdbserver :5039 /system/bin/executable       
(note: The :5039 tells gdbserver to listen on port 5039 on the localhost, which adb bridges from the host to the device. executable represents the command to debug, a common one being runtime -s which starts the entire system all running in a single process.)

b. Launch gdb on the desktop. This can be done easily with the following command in the shell from which you built =>

    $ gdbclient executable

ref: 

10. Android Source code

    a. Android GIT repositories - https://android.googlesource.com/

    c. Android AOSP bionic source code - https://github.com/android/platform_bionic

    d. Download Android AOSP source code - http://source.android.com/source/downloading.html