Created at:

Modified at:

Android development notes

Introduction

Setting SDK and building your application

I'm not interested in download Android Studio, which is a full-featured IDE. I just want to download the Android SDK to allow me to build and debug applications.

Download and unpack from the Android SDK the latest release:

    $ wget http://dl.google.com/android/android-sdk_r24.3.2-linux.tg
    $ tar zxf android-sdk_r24.3.2-linux.tgz

Enter Android SDK directory and execute the android command without parameters:

    $ cd android-sdk-linux/
    $ tools/android

This will open a GUI interface which will allow you to download libraries and tools for different API versions. Choose your API (latest recommended). It is necessary to mark both the API version checkbox (e.g. "Android 4.4.2 (API 19)") and the Build-tools package (e.g. "Android SDK Build-tools 19.1").

Creating, building and running the application

Create an Android project

In summary you have to use the android command to setup the skeleton of the project or update it. This is done with android create subcommand. Also, you may want to update properties of an existing project with android update. For instance, to change the API version of the project:

    $ ~/android-sdk-linux/tools/android update project --path `pwd` --target 'android-20'

This command will update the API version of the project. (What it actually does, is to change some configuration files that could be changed manually, but it always recommended to use android command).

Next, use ant to build the project:

    $ ant release

Or:

    $ ant debug

Some notes about Ant

Finally, install it in your device (previously connected via a USB cable - in the device Settings, don't forget to enable "USB debugging" under "Developer Options"):

    $ adb install -r bin/SGit-debug.apk

The -r flag forces the installation of the program in the device, overwriting a previous installation.

Logging of the program can be accessed from the computer with adb logcat:

    $ adb logcat MyApp:D *:S

The command above will enable printing of debug level (D) of "MyApp" and all other will remain silent (S).

Information on logging