How to install Android SDK in Windows XP or Vista,Mac OS X 10.4.8 or later,Linux


System Requirements

In order for the first use of the Android SDK and tools for the development of the code, you must, of course, a suitable environment for development.

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 an environment suitable for development, such as:

Blackout

Eclipse 3.2, 3.3 (Europe)

Android Development Tools plugin (optional)

Other development environments or IDE

JDK 5 or JDK 6 (JRE alone is not sufficient)

Not compatible with the GNU compiler for Java (GCJ)

Apache Ant 1.6.5 or later for Linux and Mac 1.7 or later for Windows

The installation of the Android SDK

First, you download the Android SDK package. Zip file downloaded on to find a mounting location on your machine and decompress zip files.

Note: The location of the facility will be referred to $ SDK_ROOT from now with this tutorial

Otherwise, you can add / tools for the root path that avoids the need to specify the full path to the directory with tools allowing you to run Android Debug Bridge (ADB) with other command line tools.

To add / tools:

Linux

Edit ~ /. Bash_profile or ~ /. Bashrc to find a line that sets the PATH variable.

Add the full path to file $ SDK_ROOT / location tools to the PATH variable.

If no PATH line, you can add the line, type the following command:

export PATH = $ {PATH}: <path to your $SDK_ROOT/tools>

Mac OS X

In the directory to locate the bash_profile. And the location of the PATH variable to add the location of your SDK_ROOT / Tools folder.

Windows XP / Vista

Right click on My Computer icon and select the Properties tab.

Select the Advanced tab and click Environment Variables.

In the new dialog box, click Path dowble (under System Variables), and type the full path to the location of the instruments.

Android SDK also requires an appropriate development environment to work, here are the installation instructions for each of the supported environments.

Android Eclipse Plugin (ADT)

If you decide to use the Eclipse IDE for Android development environment you will be able to install and use the plug-in called Android development tools. ADT contains a set of powerful tools and plug-ins that make creating, running, and debugging Android applications much easier and faster.

To download and install ADT, you must first set up an Eclipse update remotely, this can be achieved through the following steps:

Start Eclipse and select Help&gt; Software Updates&gt; Find and Install ....

In the dialog box that appears, select Search for new features to install and click Next.

Press New Remote.

In the dialog box that appears, type a name for the remote site (eg Android Plugin) and enter this as its URL: https://dl-ssl.google.com/android/eclipse/.

Press OK.

You should now see your new site is added to the search list (and checked).

Press Finish.

Results in a second dialog box Android Plugin&gt; Eclipse&gt; Android development tools integration and click Next.

Read the license agreement and select I accept the terms of the license agreement, if any.

Click Next.

Click Finish.

ADT plugin is not signed, and you can accept the installation anyway by pressing Install All.

Restart Eclipse.

After restart, update your Eclipse preferences to point to the SDK root directory ($ SDK_ROOT)

Select Window&gt; Preferences ... to open the menu settings. (Mac OS X: Eclipse&gt; Preferences)

Select Android from the left panel.

For the location of the SDK in the main panel, click Browse ... and find the root directory of the SDK.

Click Apply, then OK

Updating the ADT plugin

To update the ADT plugin to the latest version, follow these steps:

Choose Help&gt; Software Updates&gt; Find and Install ....

Select Search for updates of currently installed features and press Finish.

If any update for ADT, select and install.

Alternatively:

Click Help&gt; Software Updates&gt; Manage Configuration.

Browse the tree and select Android Development Tools <version>

Select Scan for Updates under Available Tasks.

How to use Eclipse to develop Android applications

To begin to develop applications for Android, you must first create a new Android project and then set a launch configuration. Once completed, have the ability to write, run and debug their designs Android.

In the following sections below will give you instructions on how to get you started with Android assuming you have installed the ADT plugin (as mentioned above) in your Eclipse environment.

Create a new Android project

Plugin Android Development Tools provides a friendly wizard to create new projects that allow us to create new Eclipse projects relatively quickly in new or existing code.

Choose File&gt; New&gt; Project

Select Android&gt; Android Project and click Next

Select the content of the project:

Select Create a new project in the workspace to start a project for the new code. Enter the name of the project, the base package name, the name of a class activity to create a single bead. Java, and a name to use for your application.

Select Create project from existing sources to start a project of existing code. Use this option if you want to create and run the sample applications provided with the SDK. The sample applications are found in the samples / directory in the SDK. Navigate to the directory containing the existing source code and click OK. If the directory contains a valid manifest Android ADT plugin fills in the names of the packages, the activity and the application for you.

Click Finish.

Once the ADT plugin to go ahead and create the following files and folders on your case for the project type:

src / A folder that contains your heel. Java file activity.

res / resources folder.

AndroidManifest.xml manifesto of the project.

The creation of the Eclipse launch configuration

To be able to run and debug the Eclipse application itself, you must first create a launch configuration. Just a launch configuration is used to specify the launch of the project, activity initiation and specific emulation options for use.

To create a launch configuration utility, see the following:

First Select Run&gt; Open Run dialog box ... or dialog Run&gt; Debug ... Open what is relevant.

2. In the Project Type list on the left, right click on the Android application and select New.

3rd Enter a name for your configuration.

Android On the fourth tab to search for projects and activities to start.

5. Emulator tab, set the desired screen, and properties of the network, and other startup options of the emulator.

6. You can configure additional options in the Common tab as desired.

7. Click Apply to save the launch configuration, or press Run or Debug (if applicable).

Running and debugging an application Eclipse

Once both steps 1 and 2 have been completed and the project and release settings are now in progress will be able to run or debug the application.

In the Eclipse main menu, select Run&gt; Run or Run Test&gt; if necessary. This command is run or debug the application, the most recently selected.

Set or change the active launch configuration, use the Configuration Manager execution, which can be accessed through the Run&gt; Open Run Dialog ... Run or Debug dialog&gt; Open ....

Running or debugging the application will trigger the following actions:

Launches the emulator, if not already running.

Compile the project if there have been changes since the last build, and install the program on the emulator.

Run the program starts.

Debugging the application starts the "Wait debug" mode, opens the perspective of debugging and the debugger is attached to the Eclipse Java application.

Develop Android applications with other tools and development environments

Although it is recommended to use Eclipse with the Android plugin to develop your applications, the SDK also includes tools to help you develop with other IDE with IntelliJ (alternatively, you can just use the Eclipse plugin, without) .

Creating an Android Project

Comes with the Android SDK is a program called activityCreatory. activityCreator will generate a series of "stub" files to your chosen project next to a build file. This can be used either to create an Android project for new code or existing code.

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

ActivityCreator to guide and create the Android project, proceed as follows:

At the command line, change the tools / directory of the SDK and create a new project file directory. If you create a project code, replace the root of your application, however.

ActivityCreator Run. In the command, you must specify the full class name as argument. When you create a new draft code, the class is named after a kind of effort that the script created. If you create a project from existing code, you must specify the name of a class of activities in the package. Control options for the script are:

Departure <folder> where the output directory. The default output directory is the current directory. If you created a new project file directory, use this option makes sense.

IntelliJ IDEA, which generates files of IntelliJ IDEA project in the newly created project

Here's an example:

/ Android_linux_sdk / tools $. / Myproject ActivityCreator.py out your.package.name.ActivityName

Package: your.package.name

out_dir: myproject

activity_name: ActivityName

~ / Android_linux_sdk / tools $

ActivityCreator script generates the following files and directories (but not replace existing ones):

AndroidManifest.xml application manifest file, synchronized to business class specified in the project.

Ant build.xml file, which allows you to build / package the application.

src / your / package / name / ActivityName.java activity class you specified as input.

your_activity.iml, your_activity.ipr, your_activity.iws [IntelliJ IDE only flag] IntelliJ project files.

res / A directory of resources to sustain.

src / The source directory.

bin / build script output directory.

Once completed, it will now be able to move the folder where you choose for development, but will have to take into account, then you will have to use the Asian Development Bank in the Tools folder to send files to the emulator.

How-to build an Android application

This lets you use the build.xml file generated activityCreator ANT to build the application.

If you have not, you can get Ant from the Apache Ant home page. Install and make sure it is in the path of the program.

Before calling the ant, you must declare the JAVA_HOME environment variable to specify the path where the JDK is installed.Note: When installing the JDK on Windows, by default it installs in the folder "Program Files". This causes the ants to fail for lack of space. To solve the problem, you can specify the JAVA_HOME variable like this: set JAVA_HOME = c: \ Prora ~ 1 \ Java \. The simplest solution, however, is to install the JDK in a directory other than space, for example: C: \ Java \ jdk1.6.0_02.

If you have not already done so, follow the instructions to create a new project to set up the project.

You can now run the Ant by typing ant in the same folder as the build.xml file to the project. Each time you change the source file or resource, run ant again, and is packed with the latest applications.

Mode to execute an Android application

To run a compiled program, you must first download the APK in / data / app / folder in the emulator using adb tool.:

Start the emulator (run $ SDK_HOME / tools / emulator from the command line)

On the emulator, go to the home screen (it is better not to have the program running when you install the emulator, press the Home button to navigate away from this application).

Run adb install myproject / bin / <appname> . APK to download the executable file. Thus, for example, will install Lunar Lander sample, navigate the command line to SDK_ROOT $ / sample / LunarLander and write .. / .. / Tools / adb install bin / LunarLander.apk

In the emulator, open the list of available applications, and browse to select and launch the application.

Please note: When you install an event for the first time, you may need to restart the engine emulator for the activity to appear in the application launcher or before any other application can call. This is usually the fact that the package manager normally only investigates entirely clear on how to start the emulator.

Method of attaching a debugger to your application

The following section describes how to display debug information right on the screen (eg, CPU utilization). It also shows how you can connect the IDE to debug applications running in the emulator.

The Eclipse plug-in automatically associates a debugger, but can be configured to wait another IDE in a debug port as follows:

Dalvik Start Debug Server Monitor (GDDS) tool that serves as a service port forwarding between your IDE and the emulator.

Set the debug configuration option for the emulator, how to prevent the application start-up until the debugger is attached. Please note that many of these debugging options can be used without the DDMS, such as CPU usage or frequency of updating the screen display is an emulator.

Specify the IDE connect port 8700 for debugging. We have included more information on how to set Eclipse to debug the project.

How to configure the IDE to debug the connection port

GDDS automatically assigned a given debug port for each virtual machine that recorded the emulator. You need to either connect your IDE to that port, or use a default port 8700 to connect to what application is currently selected in the list of discovered virtual machines.

Ideally, you connect the IDE application running on an emulator, which shows the wires and allows you to stop, study, or set breakpoints. If you choose "Wait for debugger" in the panel of development, would cause the application to run Eclipse to connect because you have to put all items you want to stop before connecting. If you change to debug your application, or "Wait for debugger" system, then kill the selected operation.

This can be useful if your application is in bad shape, just go to settings and activate the checkbox to kill him.

Debugging Android

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

GDDS - A graphics program supports port forwarding (so you can set breakpoints in the code in the IDE), snapshots of information in the emulator, cable and battery, and many other features. You can also run logcat to retrieve your messages. See related topic for more information.

logcat - Backing up a log of system messages. The messages include a stack trace when the emulator generates an error and log messages. To run logcat, see links. ...

I / MemoryDealer (763): MemoryDealer (this = 0 × 54bda0): Create a bunch 2,621,440 bytes 0 × 438db000

I / Logger (1858): GetView () to request the number 0

E / Logger (1858): getView () requesting item number 1

E / Logger (1858): getView () requesting item number 2

D / ActivityManager (763): stop: recording the history 409dbb20 com.google.android.home.AllApps {}

Android Log class registration to print messages to a log file is an emulator. You can read messages in real time, if you run a DDMS logcat (forward). Add some 'the method of recording calls to the code.

To use the class registration, simply call Log.v () (detailed) Log.d () (debug) Multiple () (information), Log.w () (warning) or registration. (Error) depending on the importance that you want the log message.

Contr ("MyActivity", "MyClass.getView () - for the number of" location +) can be used to read these messages logcat

Traceview - Android can be stored in log and calls the log file once, you can display a graphic called Traceview reader. See related topics for more information.

Eclipse Plugin - The Android Eclipse plugin integrates a number of these tools (ADB GDDS logcat production, and other features). See related topic for more information.

Debugging and testing the Device Settings - Android exposes several settings that expose useful information such as CPU usage and frame rate.

Debugging and test configuration on the device

Android lets you define a number of options that will make it much easier to test and debug your applications.

Go to the development of the settings page, just go to the emulator Dev Tools&gt; Options development. This in turn opens up the development of the settings page, the following settings (in mm):

App to debug an application will select debug. You need not be connected to the correction of an error, but setting this value has two effects:

This will avoid throwing an error if Android you stop at a breakpoint in a long time while debugging.

This allows you to select the Allow debugger to suspend the program start until your debugger attached (described below).

Wait blocks debugger load the selected program to a debugger attached. This way you can put a breakpoint in onCreate (), which is important to examine the process of starting a business. When you change this setting, all running instances of the selected program will be killed. For checking this box, you have to be a debugging application as described in the previous model. You can do the same by adding waitForDebugger () to your code.

Activities immediately destroy the system to destroy a business when he was arrested (as if Android had to recover the memory). This is very useful for testing onFreeze (package) / onCreate (android.os.Bundle) code path, which would otherwise be difficult to force. Choosing this option is likely to reveal a number of implementation problems due to the state of not saving.

Updates the screen flashes pink rectangle in all sections of momentary screen redraw. This is very useful to find a picture of the screen useless.

Show CPU usage Displays CPU meter in the top of the screen that shows how much CPU is used. The top bar shows the red total processor utilization, and the green line below shows the CPU time in the composition of the screen. Note: You can not disable this feature when it is turned on without restarting the emulator.

Show FPS display the current frame rate. Mostly useful to see the games around the frame rates achieved. Note: You can disable this function when it is turned on without restarting the emulator.

See background displays a background pattern in the absence of the screens are visible. This is usually not the case, but it can happen during debugging.