blob: 2080873eaf584dcc24ae3c2a2fae2eeecd3de1d4 [file] [log] [blame]
Scott Mainbd13c242009-04-21 19:09:24 -07001page.title=Developing In Other IDEs
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002@jd:body
3
Scott Mainbd13c242009-04-21 19:09:24 -07004<div id="qv-wrapper">
5<div id="qv">
6 <h2>In this document</h2>
7 <ol>
8 <li><a href="#CreatingAProject">Creating an Android Project</a></li>
9 <li><a href="#Signing">Preparing to Sign Your Application</a></li>
10 <li><a href="#Building">Building Your Application</a>
11 <ol>
12 <li><a href="#DebugMode">Building in debug mode</a></li>
13 <li><a href="#ReleaseMode">Building in release mode</a></li>
14 </ol>
15 </li>
16 <li><a href="#Running">Running Your Application</a></li>
17 <li><a href="#AttachingADebugger">Attaching a Debugger to Your Application</a></li>
18 </ol>
19
20 <h2>See also</h2>
21 <ol>
Scott Main8a4c53a2009-04-24 13:41:44 -070022 <li><a href="{@docRoot}guide/developing/tools/othertools.html#android">android Tool</a></li>
Scott Mainbd13c242009-04-21 19:09:24 -070023 <li><a href="{@docRoot}guide/developing/tools/emulator.html">Android Emulator</a></li>
24 <li><a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a></li>
25 </ol>
26</div>
27</div>
28
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029<p>The recommended way to develop an Android application is to use
Scott Mainbd13c242009-04-21 19:09:24 -070030<a href="{@docRoot}guide/developing/eclipse-adt.html">Eclipse with the ADT plugin</a>.
31The ADT plugin provides editing, building, debugging, and .apk packaging and signing functionality
32integrated right into the IDE.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033
Scott Mainbd13c242009-04-21 19:09:24 -070034<p>However, if you'd rather develop your application in another IDE, such as IntelliJ,
35or in a basic editor, such as Emacs, you can do that instead. The SDK
36includes all the tools you need to set up an Android project, build it, debug it and then
37package it for distribution. This document is your guide to using these tools.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038
39
Scott Mainbd13c242009-04-21 19:09:24 -070040<h2 id="EssentialTools">Essential Tools</h2>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041
Scott Mainbd13c242009-04-21 19:09:24 -070042<p>When developing in IDEs or editors other than Eclipse, you'll require
43familiarity with the following Android SDK tools:</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044
Scott Mainbd13c242009-04-21 19:09:24 -070045<dl>
Scott Main8a4c53a2009-04-24 13:41:44 -070046 <dt><a href="{@docRoot}guide/developing/tools/othertools.html#android">android</a></dt>
Scott Mainbd13c242009-04-21 19:09:24 -070047 <dd>To create/update Android projects and to create/move/delete AVDs.</dd>
48 <dt><a href="{@docRoot}guide/developing/tools/emulator.html">Android Emulator</a></dt>
49 <dd>To run your Android applications on an emulated Android platform.</dd>
50 <dt><a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a></dt>
51 <dd>To interface with your emulator or connected device (install apps,
52 shell the device, issue commands, etc.).
53 </dd>
54</dl>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055
Scott Mainbd13c242009-04-21 19:09:24 -070056<p>In addition to the above tools, included with the SDK, you'll use the following
57open source and third-party tools:</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080058
Scott Mainbd13c242009-04-21 19:09:24 -070059<dl>
60 <dt>Ant</dt>
61 <dd>To compile and build your Android project into an installable .apk file.</dd>
62 <dt>Keytool</dt>
63 <dd>To generate a keystore and private key, used to sign your .apk file.</dd>
64 <dt>Jarsigner (or similar signing tool)</dt>
65 <dd>To sign your .apk file with a private key generated by keytool.</dd>
66</dl>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080067
Scott Mainbd13c242009-04-21 19:09:24 -070068<p>In the topics that follow, you'll be introduced to each of these tools as necessary.
69For more advanced operations, please read the respective documentation for each tool.</p>
70
71
72<h2 id="CreatingAProject">Creating an Android Project</h2>
73
74<p>To create an Android project, you must use the <code>android</code> tool. When you create
75a new project with <code>android</code>, it will generate a project directory
76with some default application files, stub files, configuration files and a build file.</p>
77
78
79<h3 id="CreatingANewProject">Creating a new Project</h3>
80
81<p>If you're starting a new project, use the <code>android create project</code>
82command to generate all the necessary files and folders.</p>
83
84<p>To create a new Android project, open a command-line,
85navigate to the <code>tools/</code> directory of your SDK and run:</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080086<pre>
Scott Mainbd13c242009-04-21 19:09:24 -070087android create project \
Scott Main23110e42009-09-02 10:25:09 -070088--target <em>&lt;target_ID&gt;</em> \
89--name <em>&lt;your_project_name&gt;</em> \
Scott Mainbd13c242009-04-21 19:09:24 -070090--path <em>/path/to/your/project</em> \
91--activity <em>&lt;your_activity_name&gt;</em> \
92--package <em>&lt;your_package_namespace&gt;</em>
93</pre>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080094
95<ul>
Scott Mainbd13c242009-04-21 19:09:24 -070096 <li><code>target</code> is the "build target" for your application. It corresponds
97 to an Android platform library (including any add-ons, such as Google APIs) that you would like to
98 build your project against. To see a list of available targets and their corresponding IDs,
99 execute: <code>android list targets</code>.</li>
Scott Main23110e42009-09-02 10:25:09 -0700100 <li><code>name</code> is the name for your project. This is optional. If provided, this name will be used
101 for your .apk filename when you build your application.</li>
Scott Mainbd13c242009-04-21 19:09:24 -0700102 <li><code>path</code> is the location of your project directory. If the directory does not exist,
103 it will be created for you.</li>
Scott Main23110e42009-09-02 10:25:09 -0700104 <li><code>activity</code> is the name for your default {@link android.app.Activity} class. This class file
Scott Mainbd13c242009-04-21 19:09:24 -0700105 will be created for you inside
Scott Main23110e42009-09-02 10:25:09 -0700106 <code><em>&lt;path_to_your_project&gt;</em>/src/<em>&lt;your_package_namespace_path&gt;</em>/</code>.
107 This will also be used for your .apk filename unless you provide a the <code>name</code>.</li>
Scott Mainbd13c242009-04-21 19:09:24 -0700108 <li><code>package</code> is the package namespace for your project, following the same rules as for
109 packages in the Java programming language.</li>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800110</ul>
111
Scott Mainbd13c242009-04-21 19:09:24 -0700112<p>Here's an example:</p>
113<pre>
114android create project \
115--target 1 \
Scott Main23110e42009-09-02 10:25:09 -0700116--name MyAndroidApp \
117--path ./MyAndroidAppProject \
118--activity MyAndroidAppActivity \
119--package com.example.myandroid
Scott Mainbd13c242009-04-21 19:09:24 -0700120</pre>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800121
Scott Mainbd13c242009-04-21 19:09:24 -0700122<p>The tool generates the following files and directories:</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800123
Scott Mainbd13c242009-04-21 19:09:24 -0700124<ul>
125 <li><code>AndroidManifest.xml</code> - The application manifest file,
126 synced to the specified Activity class for the project.</li>
127 <li><code>build.xml</code> - Build file for Ant.</li>
128 <li><code>default.properties</code> - Properties for the build system. <em>Do not modify
129 this file</em>.</li>
130 <li><code>build.properties</code> - Customizable properties for the build system. You can edit this
Scott Main23110e42009-09-02 10:25:09 -0700131 file to override default build settings used by Ant and provide a pointer to your keystore and key alias
132 so that the build tools can sign your application when built in release mode.</li>
Scott Mainbd13c242009-04-21 19:09:24 -0700133 <li><code>src<em>/your/package/namespace/ActivityName</em>.java</code> - The Activity class
134 you specified during project creation.</li>
135 <li><code>bin/</code> - Output directory for the build script.</li>
136 <li><code>gen/</code> - Holds <code>Ant</code>-generated files, such as <code>R.java</code>. </li>
137 <li><code>libs/</code> - Holds private libraries.</li>
138 <li><code>res/</code> - Holds project resources.</li>
139 <li><code>src/</code> - Holds source code.</li>
140 <li><code>tests/</code> - Holds a duplicate of all-of-the-above, for testing purposes.</li>
141</ul>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800142
Scott Mainbd13c242009-04-21 19:09:24 -0700143<p>Once you've created your project, you're ready to begin development.
144You can move your project folder wherever you want for development, but keep in mind
145that you must use the <a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a>
146(adb) &mdash; located in the SDK <code>tools/</code> directory &mdash; to send your application
147to the emulator (discussed later). So you need access between your project solution and
148the <code>tools/</code> folder.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800149
Scott Main23110e42009-09-02 10:25:09 -0700150<p class="caution"><strong>Caution:</strong> You should refrain from moving the
Scott Mainbd13c242009-04-21 19:09:24 -0700151location of the SDK directory, because this will break the build scripts. (They
152will need to be manually updated to reflect the new SDK location before they will
153work again.)</p>
154
155
156<h3 id="UpdatingAProject">Updating a project</h3>
157
158<p>If you're upgrading a project from an older version of the Android SDK or want to create
159a new project from existing code, use the
160<code>android update project</code> command to update the project to the new development
161environment. You can also use this command to revise the build target of an existing project
Scott Main23110e42009-09-02 10:25:09 -0700162(with the <code>--target</code> option) and the project name (with the <code>--name</code>
163option). The <code>android</code> tool will generate any files and
Scott Mainbd13c242009-04-21 19:09:24 -0700164folders (listed in the previous section) that are either missing or need to be updated,
165as needed for the Android project.</p>
166
167<p>To update an existing Android project, open a command-line
168and navigate to the <code>tools/</code> directory of your SDK. Now run:</p>
169<pre>
Scott Main23110e42009-09-02 10:25:09 -0700170android update project --name <em>&lt;project_name&gt;</em> --target <em>&lt;target_ID&gt;</em> --path <em>path/to/your/project/</em>
Scott Mainbd13c242009-04-21 19:09:24 -0700171</pre>
172
173<ul>
174 <li><code>target</code> is the "build target" for your application. It corresponds to
175 an Android platform library (including any add-ons, such as Google APIs) that you would
176 like to build your project against. To see a list of available targets and their corresponding IDs,
177 execute: <code>android list targets</code>.</li>
178 <li><code>path</code> is the location of your project directory.</li>
Scott Main23110e42009-09-02 10:25:09 -0700179 <li><code>name</code> is the name for the project. This is optional&mdash;if you're not
180 changing the project name, you don't need this.</li>
Scott Mainbd13c242009-04-21 19:09:24 -0700181</ul>
182
183<p>Here's an example:</p>
184<pre>
Scott Main23110e42009-09-02 10:25:09 -0700185android update project --name MyApp --target 2 --path ./MyAppProject
Scott Mainbd13c242009-04-21 19:09:24 -0700186</pre>
187
188
189<h2 id="Signing">Preparing to Sign Your Application</h2>
190
191<p>As you begin developing Android applications, understand that all
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800192Android applications must be digitally signed before the system will install
Scott Mainbd13c242009-04-21 19:09:24 -0700193them on an emulator or device. There are two ways to do this:
194with a <em>debug key</em> (for immediate testing on an emulator or development device)
195or with a <em>private key</em> (for application distribution).</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800196
Scott Mainbd13c242009-04-21 19:09:24 -0700197<p>The Android build tools help you get started by automatically signing your .apk
198files with a debug key at build time. This means
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800199that you can compile your application and install it on the emulator without
200having to generate your own private key. However, please note that if you intend
Scott Mainbd13c242009-04-21 19:09:24 -0700201to publish your application, you <strong>must</strong> sign the application with your
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800202own private key, rather than the debug key generated by the SDK tools. </p>
203
Scott Mainbd13c242009-04-21 19:09:24 -0700204<p>Please read <a href="{@docRoot}guide/publishing/app-signing.html">Signing Your
205Applications</a>, which provides a thorough guide to application signing on Android
206and what it means to you as an Android application developer.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800207
208
Scott Mainbd13c242009-04-21 19:09:24 -0700209
210<h2 id="Building">Building Your Application</h2>
211
212<p>There are two ways to build your application: one for testing/debugging your application
213&mdash; <em>debug mode</em> &mdash; and one for building your final package for release &mdash;
214<em>release mode</em>. As described in the previous
215section, your application must be signed before it can be installed on an emulator
216or device.</p>
217
218<p>Whether you're building in debug mode or release mode, you
219need to use the Ant tool to compile and build your project. This will create the .apk file
220that is installed onto the emulator or device. When you build in debug mode, the .apk
221file is automatically signed by the SDK tools with a debug key, so it's instantly ready for installation
222(but only onto an emulator or attached development device).
223When you build in release mode, the .apk file is <em>unsigned</em>, so you must manually
224sign it with your own private key, using Keytool and Jarsigner.</p>
225
226<p>It's important that you read and understand
227<a href="{@docRoot}guide/publishing/app-signing.html">Signing Your Applications</a>, particularly
228once you're ready to release your application and share it with end-users. That document describes
229the procedure for generating a private key and then using it to sign your .apk file.
230If you're just getting started, however,
231you can quickly run your applications on an emulator or your own development device by building in
232debug mode.</p>
233
234<p>If you don't have Ant, you can obtain it from the
235<a href="http://ant.apache.org/">Apache Ant home page</a>. Install it and make
236sure it is in your executable PATH. Before calling Ant, you need to declare the JAVA_HOME
237environment variable to specify the path to where the JDK is installed.</p>
238
239<p class="note"><strong>Note:</strong> When installing JDK on Windows, the default is to install
240in the "Program Files" directory. This location will cause <code>ant</code> to fail, because of
241the space. To fix the problem, you can specify the JAVA_HOME variable like this:
242<code>set JAVA_HOME=c:\Prora~1\Java\<jdkdir></code>. The easiest solution, however, is to
243install JDK in a non-space directory, for example: <code>c:\java\jdk1.6.0_02</code>.</p>
244
245
246<h3 id="DebugMode">Building in debug mode</h3>
247
248<p>For immediate application testing and debugging, you can build your application
Scott Main23110e42009-09-02 10:25:09 -0700249in debug mode and immediately install it on an emulator. In debug mode, the build tools
250automatically sign your application with a debug key and optimize the package with
251{@code zipalign}. However, you can (and should) also test your
Scott Mainbd13c242009-04-21 19:09:24 -0700252application in release mode. Debug mode simply allows you to run your application without
253manually signing the application.</p>
254
255<p>To build in debug mode:</p>
256
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800257<ol>
Scott Mainbd13c242009-04-21 19:09:24 -0700258 <li>Open a command-line and navigate to the root of your project directory.</li>
259 <li>Use Ant to compile your project in debug mode:
260 <pre>ant debug</pre>
Scott Main23110e42009-09-02 10:25:09 -0700261 <p>This creates your debug .apk file inside the project <code>bin/</code>
262 directory, named <code><em>&lt;your_project_name&gt;</em>-debug.apk</code>. The file
263 is already signed with the debug key and has been aligned with {@code zipalign}.</p>
Scott Mainbd13c242009-04-21 19:09:24 -0700264 </li>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800265</ol>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800266
Scott Mainbd13c242009-04-21 19:09:24 -0700267<p>Each time you change a source file or resource, you must run Ant
268again in order to package up the latest version of the application.</p>
269
270<p>To install and run your application on an emulator, see the following section
271about <a href="#Running">Running Your Application</a>.</p>
272
273
274<h3 id="ReleaseMode">Building in release mode</h3>
275
276<p>When you're ready to release and distribute your application to end-users, you must build
277your application in release mode. Once you have built in release mode, it's a good idea to perform
278additional testing and debugging with the final .apk.</p>
279
Scott Main23110e42009-09-02 10:25:09 -0700280<p>Before you start building your application in release mode, be aware that you must sign
281the resulting application package with your private key, and should then align it using the
282{@code zipalign} tool. There are two approaches to building in release mode:
283build an unsigned package in release mode and then manually sign and align
284the package, or allow the build script
285to sign and align the package for you.</p>
286
287<h4 id="ManualReleaseMode">Build unsigned</h4>
288
289<p>If you build your application <em>unsigned</em>, then you will need to
290manually sign and align the package.</p>
291
292<p>To build an <em>unsigned</em> .apk in release mode:</p>
Scott Mainbd13c242009-04-21 19:09:24 -0700293
294<ol>
295 <li>Open a command-line and navigate to the root of your project directory.</li>
296 <li>Use Ant to compile your project in release mode:
297 <pre>ant release</pre>
Scott Mainbd13c242009-04-21 19:09:24 -0700298 </li>
299</ol>
300
Scott Main23110e42009-09-02 10:25:09 -0700301<p>This creates your Android application .apk file inside the project <code>bin/</code>
302directory, named <code><em>&lt;your_project_name&gt;</em>-unsigned.apk</code>.</p>
303
304<p class="note"><strong>Note:</strong> The .apk file is <em>unsigned</em> at this point
305and can't be installed until signed with your private key.</p>
306
307<p>Once you have created the unsigned .apk, your next step is to sign the .apk
308with your private key and then align it with {@code zipalign}. To complete this procedure,
Scott Mainbd13c242009-04-21 19:09:24 -0700309read <a href="{@docRoot}guide/publishing/app-signing.html">Signing Your Applications</a>.</p>
310
Scott Main23110e42009-09-02 10:25:09 -0700311<p>When your .apk has been signed and aligned, it's ready to be distributed to end-users.</p>
312
313<h4 id="AutoReleaseMode">Build signed and aligned</h4>
314
315<p>If you would like, you can configure the Android build script to automatically
316sign and align your application package. To do so, you must provide the path to your keystore
317and the name of your key alias in your project's {@code build.properties} file. With this
318information provided, the build script will prompt you for your keystore and alias password
319when you build in release mode and produce your final application package, which will be ready
320for distribution.</p>
321
322<p class="caution"><strong>Caution:</strong> Due to the way Ant handles input, the password that
323you enter during the build process <strong>will be visible</strong>. If you are
324concerned about your keystore and alias password being visible on screen, then you
325may prefer to perform the application signing manually, via Jarsigner (or a similar tool). To instead
326perform the signing procedure manually, <a href="#ManualReleaseMode">buid unsigned</a> and then continue
327with <a href="{@docRoot}guide/publishing/app-signing.html">Signing Your Applications</a>.</p>
328
329<p>To specify your keystore and alias, open the project {@code build.properties} file (found in the
330root of the project directory) and add entries for {@code key.store} and {@code key.alias}.
331For example:</p>
332
333<pre>
334key.store=/path/to/my.keystore
335key.alias=mykeystore
336</pre>
337
338<p>Save your changes. Now you can build a <em>signed</em> .apk in release mode:</p>
339
340<ol>
341 <li>Open a command-line and navigate to the root of your project directory.</li>
342 <li>Use Ant to compile your project in release mode:
343 <pre>ant release</pre>
344 </li>
345 <li>When prompted, enter you keystore and alias passwords.
346 <p class="caution"><strong>Caution:</strong> As described above,
347 your password will be visible on the screen.</p>
348 </li>
349</ol>
350
351<p>This creates your Android application .apk file inside the project <code>bin/</code>
352directory, named <code><em>&lt;your_project_name&gt;</em>-release.apk</code>.
353This .apk file has been signed with the private key specified in
354{@code build.properties} and aligned with {@code zipalign}. It's ready for
355installation and distribution.</p>
356
357
358<h4>Once built and signed in release mode</h4>
359
Scott Mainbd13c242009-04-21 19:09:24 -0700360<p>Once you have signed your application with a private key, you can install it on an
361emulator or device as discussed in the following section about
362<a href="#Running">Running Your Application</a>.
363You can also try installing it onto a device from a web server.
364Simply upload the signed APK to a web site, then load the .apk URL in your Android web browser to
365download the application and begin installation.
366(On your device, be sure you have enabled <em>Settings > Applications > Unknown sources</em>.)</p>
367
368
369<h2 id="Running">Running Your Application</h2>
370
371<p>Unless you'll be running your application on device hardware,
372you need to launch an emulator upon which you will install your application.
373An instance of the Android emulator runs a specific Android platform with specific device configuration
374settings. The platform and configuration is defined with an Android Virtual Device (AVD).
375So before you can launch your emulator, you must define an AVD.</p>
376
377<p>If you'll be running your application on device hardware, please read about
378<a href="{@docRoot}guide/developing/device.html">Developing On a Device</a> instead.</p>
379
380<ol>
381 <li><strong>Create an AVD</strong>
382 <ol>
383 <li>Open a command-line and navigate to your SDK package's
384 <code>tools/</code> directory.</li>
385 <li>First, you need to select a "deployment target." To view available targets, execute:
386 <pre>android list targets</pre>
387 <p>This will output a list of available Android targets, such as:</p>
388<pre>
389id:1
390 Name: Android 1.1
391 Type: platform
392 API level: 2
393 Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
394id:2
395 Name: Android 1.5
396 Type: platform
397 API level: 3
398 Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
399</pre>
400 <p>Find the target that matches the Android platform upon which you'd like
401 to run your application. Note the integer value of the <code>id</code> &mdash;
402 you'll use this in the next step.</p>
403 </li>
404 <li>Create a new AVD using your selected deployment target:
Scott Main23110e42009-09-02 10:25:09 -0700405 <pre>android create avd --name <em>&lt;your_avd_name&gt;</em> --target <em>&lt;target_ID&gt;</em></pre>
Scott Mainbd13c242009-04-21 19:09:24 -0700406 <li>Next, you'll be asked whether you'd like to create a custom hardware profile.
407 If you respond "yes," you'll be presented with a series of prompts to define various aspects of the
408 device hardware (leave entries blank to use default values, which are shown in brackets). Otherwise,
409 press return to use all default values ("no" is the default).</li>
410 </li>
411 </ol>
412 </li>
413
414 <li><strong>Launch an emulator</strong></li>
415 <p>From your SDK's <code>tools/</code> directory, launch an emulator
416 using an existing AVD (created above):
417 <pre>emulator -avd <em>&lt;your_avd_name&gt;</em></pre>
418 <p>An instance of the emulator will now launch, running the target and configuration
419 defined by your AVD.</p>
420 </li>
421
422 <li><strong>Install your application</strong>
423 <p>From your SDK's <code>tools/</code> directory, install the .apk on the emulator:
424 <pre>adb install <em>/path/to/your/application</em>.apk</pre>
425 <p>If there is more than one emulator running, you must specify the emulator upon which to install
426 the application, by its serial number, with the <code>-s</code> option. For example:</p>
427 <pre>adb -s emulator-5554 install /my/project/path/myapp.apk</pre>
428 </li>
429 <li><strong>Open your application</strong>
430 <p>In the emulator, open the list of available applications to find
431 and open your application.</p>
432 </li>
433</ol>
434
435<p>If you don't see your application on the emulator. Try restarting the emulator
436(with the same AVD). Sometimes when you install an Activity for the
437first time, it won't show up in the application launcher or be accessible by other
438applications. This is because the package manager usually examines manifests
439completely only on emulator startup.</p>
440
441<p class="note"><strong>Tip:</strong> If you have only one emulator running,
442you can build your application and install it on the emulator in one simple step.
443Navigate to the root of your project directory and use Ant to compile the project
444with <em>install mode</em>:
445<code>ant install</code>. This will build your application, sign it with the debug key,
446and install it on the currently running emulator.
447If there is more than one emulator currently running
448when using the <code>install</code> command, it will fail &mdash; it can't select between the
449multiple emulators.</p>
450
451<p>For more information on the tools used above, please see the following documents:</p>
452<ul>
Scott Main8a4c53a2009-04-24 13:41:44 -0700453 <li><a href="{@docRoot}guide/developing/tools/othertools.html#android">android Tool</a></li>
Scott Mainbd13c242009-04-21 19:09:24 -0700454 <li><a href="{@docRoot}guide/developing/tools/emulator.html">Android Emulator</a></li>
455 <li><a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a> (ADB)</li>
456</ul>
457
458
459<h2 id="AttachingADebugger">Attaching a Debugger to Your Application</h2>
460
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800461<p>This section describes how to display debug information on the screen (such
462 as CPU usage), as well as how to hook up your IDE to debug running applications
463 on the emulator. </p>
464
465<p>Attaching a debugger is automated using the Eclipse plugin,
466 but you can configure other IDEs to listen on a debugging port to receive debugging
Scott Mainbd13c242009-04-21 19:09:24 -0700467 information:</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800468<ol>
Scott Mainbd13c242009-04-21 19:09:24 -0700469 <li><strong>Start the <a href="{@docRoot}guide/developing/tools/ddms.html">Dalvik Debug Monitor
470 Server (DDMS)</a> tool, </strong> which
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800471 acts as a port forwarding service between your IDE and the emulator.</li>
472 <li><strong>Set
473 optional debugging configurations on
Scott Mainbd13c242009-04-21 19:09:24 -0700474 your emulator</strong>, such as blocking application startup for an Activity
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800475 until a debugger is attached. Note that many of these debugging options
476 can be used without DDMS, such as displaying CPU usage or screen refresh
477 rate on the emulator.</li>
Scott Mainbd13c242009-04-21 19:09:24 -0700478 <li><strong>Configure your IDE to attach to port 8700 for debugging.</strong> Read
479 about <a href="{@docRoot}guide/developing/debug-tasks.html#ide-debug-port">
480 Configuring Your IDE to Attach to the Debugging Port</a>. </li>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800481</ol>