Android SDK Installation Guide

Here’s a quick start installation guide to get you up and running with the Google Android Software Development Kit (SDK). This guide will describe how to install the Android SDK and set up your chosen development environments. If you’ haven’t already done so you can download the Android SDK from the link below, then we can get started.

First you’ll need to download the Android SDK source files:
  http://code.google.com/android/download.html  


System Requirements

In order to first use the Android SDK code and tools for development you will of course need a suitable environment develop from.

Currently the following operating systems are supported:

    Windows XP or Vista
    Mac OS X 10.4.8 or later (x86 only)
    Linux (tested on Linux Ubuntu Dapper Drake)

You will also need to install a suitable development environment such as:

Eclipse
    Eclipse 3.2, 3.3 (Europa)
    Android Development Tools plugin (optional)

    Other development environments or IDEs

    JDK 5 or JDK 6 (JRE alone is not sufficient)
    Not compatible with Gnu Compiler for Java (gcj)
    Apache Ant 1.6.5 or later for Linux and Mac, 1.7 or later for Windows

Installing The Android SDK


First you will need to download the Android SDK pack .zip archive, once downloaded find a suitable installation location on your machine and extract the zipped files.

Please note: This installation location will be referred to as $SDK_ROOT from now on through this tutorial

Alternatively you can add /tools to your root path which will prevent the need to specify the full path to the tools directory along with enabling you to run Android Debug Bridge (adb) along with other command line tools.

To add /tools:

Linux
  1.     Edit the ~/.bash_profile or ~/.bashrc files looking for a line that sets the PATH variable.
  2.     Add the full path location to your $SDK_ROOT/tools location for the PATH variable.
  3.     If no PATH line exists you can add the line by typing the following:
  4.     export PATH=${PATH}:

Mac OS X

  1.     In the home directory locate the .bash_profile and locating the PATH variable add the location to your $SDK_ROOT/tools folder.

Windows XP / Vista
  1.     Right click on the My Computer icon and select the properties tab.
  2.     Select the Advanced tab and click the Environment Variables button.
  3.     In the new dialog box dowble-click on Path (located under System Variables) and type in the full path location to the tools directory.

The Android SDK also requires a suitable development environment to work in, here’s the installation guides for each of the supported environments.

Android Eclipse Plugin (ADT)

If you choose to use the Eclipse IDE as your Android development environment you will have the opportunity to install and run a plug-in called Android Development Tools. ADT comes with a variety of powerful tools and extensions that will make creating, running and debugging your Android applications much easier and faster.

In order to download and install ADT you will first need to configure an Eclipse remote update, this can achieved via the following steps:
  1.     Start Eclipse, then select Help > Software Updates > Find and Install….
  2.     In the dialog that appears, select Search for new features to install and press Next.
  3.     Press New Remote Site.
  4.     In the resulting dialog box, enter a name for the remote site (e.g. Android Plugin) and enter this as its URL: https://dl-ssl.google.com/android/eclipse/.
  5.     Press OK.
  6.     You should now see the new site added to the search list (and checked).
  7.     Press Finish.
  8.     In the subsequent Search Results dialog box, select the checkbox for Android Plugin > Eclipse Integration > Android Development Tools and press Next.
  9.     Read the license agreement and then select Accept terms of the license agreement, if appropriate.
  10.     Press Next.
  11.     Press Finish.
  12.     The ADT plugin is not signed; you can accept the installation anyway by pressing Install All.
  13.     Restart Eclipse.
  14.     After restart, update your Eclipse preferences to point to the SDK root directory ($SDK_ROOT):
  15.     Select Window > Preferences… to open the Preferences panel. (Mac OS X: Eclipse > Preferences)
  16.     Select Android from the left panel.
  17.     For the SDK Location in the main panel, press Browse... and find the SDK root directory.
  18.     Press Apply, then OK

Updating the ADT Plugin


To update the ADT plugin to the latest version, follow these steps:
  1.     Select Help > Software Updates > Find and Install….
  2.     Select Search for updates of the currently installed features and press Finish.
  3.     If any update for ADT is available, select and install.

Alternatively:
  1.     Select Help > Software Updates > Manage Configuration.
  2.     Navigate down the tree and select Android Development Tools
  3.     Select Scan for Updates under Available Tasks.

How-To Use Eclipse To Develop Android Applications


In order to begin development on your Android applications you will first need to create a new Android project and then configure a launch configuration. Once completed you will have the capability to write, run and debug your Android creations.

The following sections below will provide you with the necessary instructions to get you up and running with Android provided you have installed the ADT plugin (as previously mentioned) in your Eclipse environment.
Creating A New Android Project

The Android Development Tools plugins kindly provides a Wizard for setting up new Projects which will allow us to create new Eclipse projects relatively quickly for either new or existing code.

Select File > New > Project

    Select Android > Android Project, and press Next
    Select the contents for the project:

    Select Create new project in workspace to start a project for new code. Enter the project name, the base package name, the name of a single Activity class to create as a stub .java file, and a name to use for your application.
    Select Create project from existing source to start a project from existing code. Use this option if you want to build and run any of the sample applications included with the SDK. The sample applications are located in the samples/ directory in the SDK. Browse to the directory containing the existing source code and click OK. If the directory contains a valid Android manifest file, the ADT plugin fills in the package, activity, and application names for you.

Press Finish.

Once completed the ADT plugin will go ahead and create the following files and folders as appropriate for the type of project selected:

    src/ A folder that includes your stub .java Activity file.
    res/ A folder for your resources.
    AndroidManifest.xml The manifest for your project.

Creating A Launch Configuration For Eclipse


In order to be able to run and debug your own Eclipse applications you must first create a launch configuration. Simply, a launch config is used to specify which project to launch, which activity to start and the specific emulation options to use.

To create a launch configuration for the application, please see the following steps:
1. Select Run > Open Run Dialog… or Run > Open Debug Dialog… as appropriate.
2. In the project type list on the left, right-click Android Application and select New.
3. Enter a name for your configuration.
4. On the Android tab, browse for the project and Activity to start.
5. On the Emulator tab, set the desired screen and network properties, as well as any other emulator startup options.
6. You can set additional options on the Common tab as desired.
7. Press Apply to save the launch configuration, or press Run or Debug (as appropriate).
Running and Debugging an Eclipse Application

Once both steps 1 and 2 have been completed and your project and launch configs are up and running you will now be able to run or debug your application.

From the Eclipse main menu, select Run > Run or Run > Debug as appropriate. This command will run or debug the most recently selected application.

To set or change the active launch configuration, use the Run configuration manager, which you can access through Run > Open Run Dialog… or Run > Open Debug Dialog….

Running or debugging the application will trigger the following actions:


  1.     Starts the emulator, if it is not already running.
  2.     Compile the project, if there have been changes since the last build, and installs the application on the emulator.
  3.     Run starts the application.
  4.     Debug starts the application in “Wait for debugger” mode, then opens the Debug perspective and attaches the Eclipse Java debugger to the application.

Developing Android Applications with Other IDEs and Tools


Although it is recommended you use Eclipse with the Android plugin to develop your applications, the SDK also provides tools which will enable you to develop with other IDE’s including intelliJ (alternatively you could just use Eclipse without the plugin).
Creating an Android Project

Bundled with the Android SDK is a program called activityCreatory. activityCreator will generate a number of ‘stub’ files for your chosen project alongside a build file. This can be used to either create an Android project for new code or from existing code.

For Linux and Mac users the Android SDK provides a Python script called activityCreator.py, with Windows users receiving a btach script called activityCreator.bat. The program is used in the same way regardless of operating system.

In order to run activityCreator and create an Android project, follow these steps:


    In the command line, change to the tools/ directory of the SDK and create a new directory for your project files. If you are creating a project from existing code, change to the root folder of your application instead.
    Run activityCreator. In the command, you must specify a fully-qualified class name as an argument. If you are creating a project for new code, the class represents the name of a stub class that the script will create. If you are creating a project from existing code, you must specify the name of one Activity class in the package. Command options for the script include:

–out which sets the output directory. By default, the output directory is the current directory. If you created a new directory for your project files, use this option to point to it.

–ide intellij, which generates IntelliJ IDEA project files in the newly created project
Here’s an example:

/android_linux_sdk/tools$ ./activityCreator.py –out myproject your.package.name.ActivityName
package: your.package.name
out_dir: myproject
activity_name: ActivityName
~/android_linux_sdk/tools$

The activityCreator script generates the following files and directories (but will not overwrite existing ones):


    AndroidManifest.xml The application manifest file, synced to the specified Activity class for the project.
    build.xml An Ant file that you can use to build/package the application.
    src/your/package/name/ActivityName.java The Activity class you specified on input.
    your_activity.iml, your_activity.ipr, your_activity.iws [only with the -ide intelliJ flag] intelliJ project files.
    res/ A directory to hold resources.
    src/ The source directory.
    bin/ The output directory for the build script.

Once complete you will now be able to move your folder wherever you choose for development but you’ll need to bear in mind then you will need to use the adb program in the tools folder in order to send the files to the emulator.
How-To Build An Android Application

Here’s how to use the Ant build.xml file generated by activityCreator to build your application.

    If you don’t have it, you can obtain Ant from the Apache Ant home page. Install it and make sure it is on your executable path.
    Before calling Ant, you need to declare the JAVA_HOME environment variable to specify the path to where the JDK is installed.Note: When installing JDK on Windows, the default is to install in the “Program Files” directory. This location will cause ant to fail, because of the space. To fix the problem, you can specify the JAVA_HOME variable like this: set JAVA_HOME=c:\Prora~1\Java\. The easiest solution, however, is to install JDK in a non-space directory, for example: c:\java\jdk1.6.0_02.
    If you have not done so already, follow the instructions for Creating a New Project above to set up the project.
    You can now run the Ant build file by simply typing ant in the same folder as the build.xml file for your project. Each time you change a source file or resource, you should run ant again and it will package up the latest version of the application for you to deploy.

How-To Run An Android Application


In order to run a compiled application you will first need to upload the .apk file to the /data/app/ directory in the emulator using the adb tool:

    Start the emulator (run $SDK_HOME/tools/emulator from the command line)
    On the emulator, navigate to the home screen (it is best not to have that application running when you reinstall it on the emulator; press the Home key to navigate away from that application).
    Run adb install myproject/bin/.apk to upload the executable. So, for example, to install the Lunar Lander sample, navigate in the command line to $SDK_ROOT/sample/LunarLander and type ../../tools/adb install bin/LunarLander.apk
    In the emulator, open the list of available applications, and scroll down to select and start your application.

Please Note: When installing an activity for the first time you may need to restart the emulator engine in order for the activity to show up in the application launcher or before any other application can call. This is usually down to the fact that the package manager normally only examines manifests completely on emulator start-up.
How-To Attach a Debugger to Your Application

The following section details how to display debug information directly onto the screen (for example CPU usage). It also shows you how to hook up your IDE to debug running applications on the emulator.

The Eclipse plugin automatically attaches a debugger but you can configure other IDE’s to wait on a debugging port by doing the following:

Start the Dalvik Debug Monitor Server (DDMS) tool , which acts as a port forwarding service between your IDE and the emulator.

    Set optional debugging configurations on your emulator, such as blocking application startup for an activity until a debugger is attached. Note that many of these debugging options can be used without DDMS, such as displaying CPU usage or screen refresh rate on the emulator.
    Configure your IDE to attach to port 8700 for debugging. We’ve included information higher up on how to set up Eclipse to debug your project.

How-To Configure Your IDE To Attach To The Debugging Port


DDMS will automatically assign a specific debugging port for every virtual machine that it detects on the emulator. You must either attach your IDE to that port, or use a default port 8700 to connect to whatever application is currently selected on the list of discovered virtual machines.

Ideally your IDE will attach to the application running on the emulator, showing its threads and allowing you to suspend them, inspect them, or set breakpoints. If you choose to “Wait for debugger” in the Development settings panel, this will cause the application to run when Eclipse connects therefore you will need to set any breakpoints you want before connecting. If you change the application being debugged or the “Wait for debugger” then the system will kill the selected currently running application.

This can be handy if your application is in a bad state, you can simply go to the settings and toggle the checkbox to kill it.
Debugging Android

Google Android has a fairly extensive set of tools to help you debug your programs:


    DDMS – A graphical program that supports port forwarding (so you can set up breakpoints in your code in your IDE), screen captures on the emulator, thread and stack information, and many other features. You can also run logcat to retrieve your Log messages. See the linked topic for more information.
    logcat – Dumps a log of system messages. The messages include a stack trace when the emulator throws an error, as well as Log messages. To run logcat, see the linked topic. …
    I/MemoryDealer( 763): MemoryDealer (this=0x54bda0): Creating 2621440 bytes heap at 0x438db000
    I/Logger( 1858): getView() requesting item number 0
    I/Logger( 1858): getView() requesting item number 1
    I/Logger( 1858): getView() requesting item number 2
    D/ActivityManager( 763): Stopping: HistoryRecord{409dbb20 com.google.android.home.AllApps}
    …

    Android Log- A logging class to print out messages to a log file on the emulator. You can read messages in real time if you run logcat on DDMS (covered next). Add a few logging method calls to your code.

    To use the Log class, you just call Log.v() (verbose), Log.d() (debug), Log.i() (information), Log.w() (warning) or Log.e (error) depending on the importance you wish to assign the log message.
    Log.i(“MyActivity”, “MyClass.getView() — Requesting item number ” + position) You can use logcat to read these messages
    Traceview – Android can save a log of method calls and times to a logging file that you can view in a graphical reader called Traceview. See the linked topic for more information.
    Eclipse plugin – The Eclipse Android plugin incorporates a number of these tools (ADB, DDMS, logcat output, and other functionality). See the linked topic for more information.

    Debug and Test Device Settings – Android exposes several settings that expose useful information such as CPU usage and frame rate.

How To Move Off Screen Windows Back On The Visible Screen

If you use your laptop with an external monitor and you make that monitor primary, you always need to remember switching the settings back to the initial ones before disconnecting that monitor. If you forget, you’re in trouble, because the Display Properties window doesn’t show on your screen, so you can’t access the display settings (I’m talking here about Windows-operated computers). This is very tricky, because the Display Properties box doesn’t show in the taskbar, so you have no chance to use any menus that may show up when you right-click that tab.


This is what you need to do for bringing your off-screen window back on screen :

  1. Right click anywhere on the desktop (on the free space, not on icons). 
The following menu will appear
       
      2.  Left click on Properties (last item on the menu that will show up after your previous command)
      3.  Press F10 on the keyboard (this will move the current cursor position on the Display Properties  window which you can’t see yet)
      4.   Press Down Arrow on the keyboard (this will activate the following menu, which you also can’t see, but I’ll show it to you here, so you realize what I’m talking about)


  •  (Notice that the current cursor position is already on the Move item)
  •     Press Enter. The Move command is now selected (but you also can’t see because the box is positioned off-screen).
  •     Press either left arrow or right arrow on the keyboard.
  •     After pressing any of the arrows once, just start moving the mouse left or right, until you see the Display Properties box on the screen.
  •     When you’re happy with the new positioning of the box, left-click once and you’re done, you can now make your laptop screen primary again and thank me for saving you from disaster.




You Can Now Print Your Very-Own 3D Covers For Lumia 820

Back in the late 90s, Nokia was the first mainstream phone company to allow customers to snap out their default phone cases and snap their own cases on, creating a custom look: this was back with the Nokia 5110. Adapting to passing times (in quite a huge way, we must say), Nokia is now allowing customers (at least those with 3D printers lying around, or able to afford a one-off print-off) to print their own cases for the Lumia 820.

This release comes in the form of the “3D-printing development kit”, or 3DK as Nokia is calling it, and includes 3D printer files with the exact dimensions needed to create perfect-fitting cases for the Lumia 820. Not only that, it also includes documentation, such as guidance on which materials can be used in order to create natural-looking and fitting cases.

While this is not likely to be taken up by too many just yet, it will likely be more than welcome by enthusiasts or those who enjoy customizing their hardware. Better yet, the 3DK might just make it a lot easier for third-party case manufacturers to quickly and effectively create high-quality cases for the Lumia 820, which would in turn bring some much-needed attention to the device. Bringing a leveled playing field to case manufacturers will definitely be a plus.

If you have a 3D printer lying around, or have over a grand to spend to buy one, you can go ahead and download the 3D files right now, completely free of charge: the mechanical drawings for the back panel are available here, and those for the back shell can be found here. There are also also other services that allow users to perform one-off drawings: while they won’t come cheap either, if you’re looking to give your brand new Nokia Lumia 820 a brand-new design, you should definitely take a look at this.
If you don’t have a 3D printer lying around, it’s not the end of the world: Nokia has recently unleashed a set of skins for the Lumia, which look quite nice. Whichever way you go, it is pretty clear that Nokia is really doing a good job and compelling their users to customize their phones.

Two Weeks Later: An iPhone User’s Take On The Lumia 820 / Windows Phone 8

If you cast your minds back a couple of weeks, you may remember my tentative pledge to take on the challenge of using a Windows Phone 8 device for an entire two weeks, in place of my beloved iPhone. This, on its own, is not much to shout about, but considering I had never previously acquainted myself with Windows Phone in any way, shape or form, I suspected my fortnight with the Nokia Lumia 820 would be one of trials and tribulations.
It all began on the 8th of January. I took the SIM out of my iPhone, and cut it completely out of my life. The first few hours were tough, to say the least, but, sensing it was merely the fear of the unknown, dived in head first.

The Device


In this case, Nokia was kind enough to provide us with a Lumia 820, and although it doesn’t offer as sharp a display, slick a form factor, or precise a snapper as the Lumia 920, it offers a fairly good representation as to the current state of play in the Windows Phone market.
Needless to say, it’s a capable handset, but it’s relentlessly mid-range. Almost as though it was meant to be high-end, but Nokia purposely crippled it in order to sway the market towards the flagship device. It makes perfect sense from the company’s point of view, but means the 820 is so very nearly a great device.


The cheap, plastic back cover, which pops off to reveal the microSD, SIM and battery housing, doesn’t feel nice to hold, but that’s not the main quibble. Much has been made of both Lumias’ abilities to operate through gloves, but if you’re wearing normal, wool gloves, holding the device is almost impossible. In short, it’s slippery, but since the back cover is removable, I presume it isn’t too difficult to pick up an alternative – preferably one with more friction than a bar of soap.

Windows Phone 8 Design 2

Aside from the cheap build, I have been very pleased with the Lumia 820. The display isn’t the best, nor is the camera, but if you’re not much of a photography enthusiast, this device will serve you just fine.

Interface

There’s no doubting Windows Phone 8 is pretty to look at, but what’s really compelling, is that it actually works. The resizable, Live Tiles adapt to your preferences, and having become accustomed to the uniform arrangements of iOS and Android (save the occasional widget), the versatile, aesthetically-pleasing look of WP8 served as a refreshing change.


 There’s a slick finesse about the way Windows Phone 8 jumps in and out of apps, which makes it feel like a premium service. It airs off a sense of enthusiasm, and with Live Tiles constantly keeping you in the loop, it never seems to be taking a break, or sitting idly.


 While Android and iOS are seen by many as fairly similar in terms of looks, Windows Phone 8 is vastly different to both. At first, I thought WP8 would be impossible to adapt to, but it’s not overly complicated at all. In fact, within half an hour, most of the functions felt like second nature, and all those reservations I’d previously had about leaving my iPhone were gone.

Apps

A few of you tweeted some general recommendations of apps, tips, and I have to say, you guys really helped me out. The first thing you notice when you make the leap from a platform like iOS or Android, is that Windows Phone is still rather bereft when it comes to app count. But whereas Oliver had a bit of a struggle finding anything noteworthy for his Lumia 800 last year, I found, with a little digging, there are plenty of gems out there.


Twitter is a service that depends on well-developed apps, and having used a bunch for iOS and Android, Windows Phone’s collection is certainly on par. There aren’t as many, but the few that do exist are invariably of the highest quality, and the one I ended up falling in love with was mehdoh. Pronounced “meadow”, and costing $0.99, it does everything you could want and more, allowing effortless sliding between mentions, timeline and messages.


In terms of games and general productivity apps, I ran into many, but the shortcomings of WP8’s apps are still, unfortunately, evident in places. For example, like an increasing number of people, I use my smartphone for banking. I can move money between accounts in seconds, which is great not only for management of funds, but means I can quickly empty my account if I lose my bank card. The Windows Phone Store has no banking apps whatsoever, at least there is none for my bank in UK, and while Microsoft continues its quest to beef up the numbers of apps, the company really needs to concentrate on plugging these basic holes, which can and will turn out to be deal-breakers to many. Yes I Know there’s a native Wallet Hub in Windows Phone 8 for purchasing store gift cards, managing coupons, credit cards, making transactions using NFC and more, but it isn’t exactly what I’m looking for.

So, on the whole, the WP Store has certainly improved dramatically, and if I didn’t do my banking on the move, I might even have said something crazy, like “Windows Phone is a viable alternative to iOS / Android”. While I cannot do that, and while you will almost certainly have to make one or two sacrifices in order to adopt the enticing Windows Phone platform, you should no longer approach the topic with the kind of fear I initially did.

Browsing

Browsing the Web on the mobile version of IE was a pleasure. The gulf between browsing on a larger device versus the iPhone should not be understated, and although the iPhone 5 offers a larger longer display over previous iterations of the iconic Apple smartphone, it is still, in my opinion, no match for the larger handsets on the market.



The quality of the display meant more zooming was necessary than I would have liked, but on the whole, I felt more compelled to browse the Web on the Lumia 920 than I ever have on an iPhone.