From 01979991dc554fa64515028b6f01c1ab7be466b7 Mon Sep 17 00:00:00 2001
From: Scott Main When building mobile applications, it's vital to test them on real
-devices prior to releasing them to users. This page covers what you need to know,
-including the types of devices that you can use, and how to set one up for
-developing and debugging. When building a mobile application, it's important that you always test your application on a
+real device before releasing it to users. This page describes how to set up your development
+environment and Android-powered device for testing and debugging on the device. You can use any Android-powered device as an environment for running,
+debugging, and testing your applications. The tools included in the SDK make it easy to install and
+run your application on the device each time you compile. You can install your application on the
+device directly from
+Eclipse or from the
+command line. If
+you don't yet have a device, check with the service providers in your area to determine which
+Android-powered devices are available. Here are some options for obtaining devices capable of testing your applications. It's likely that one of your local mobile carriers offers an Android-powered device.
-Any Android-powered device (even one bought from your mobile carrier) is a perfectly good
-device for running and testing your own Android applications.
-You can write applications using the Android SDK and then install them
-directly onto the device for testing. Check with the service providers in your area to determine which Android-powered
-devices are available. Be aware that consumer devices are not designed to allow system image updates by the
-user. If you're interested in manually updating the device with custom system images, then
-you'll need a developer device such as the Android Dev Phone 1. Selected specs for Android Dev Phone 1: The Android Dev Phone 1 is a SIM-unlocked and hardware-unlocked device that
-is designed for advanced developers. The device ships with a system image that
-is fully compatible with Android 1.0, so you can rely on it when developing your
-applications. You can use any SIM in the device and can flash custom Android
-builds that will work with the unlocked bootloader. Unlike the bootloader on
-retail devices, the bootloader on the Android Dev Phone 1 does not enforce
-signed system images. The Android Dev Phone 1 should also appeal to developers
-who live in geographies where local mobile carriers do not currently offer Android-powered devices. To purchase an Android Dev Phone 1 device, you must first register as an
-Android developer on the Android Market site, if you haven't done so already.
-Once you've logged into your developer account on Android Market, you can
-purchase the device by following the link to "Development phones." To accommodate demand,
-there is a limit of 1 device per developer account, for now. The device currently costs $399 (USD) (including free shipping in the US),
-and is available for purchase in 18 international markets, including the
-US, UK, Germany, Japan, India, Canada, France, Taiwan, Spain, Australia,
-Singapore, Switzerland, Netherlands, Austria, Sweden, Finland, Poland, and
-Hungary. We will continue to expand this program into new geographies over
-time. Check this page for updated information. Android Dev Phone 1 devices are not intended for
-non-developer end-users. Because the device can be configured with system
-software not provided by or supported by Google or any other company, end-users
-operate these devices at their own risk. Note that your Android Dev Phone 1 will not receive automated
-over-the-air (OTA) updates for the system image. System updates must be flashed manually.
-See the HTC site for a guide to Flashing
-your Android Dev Phone with a Factory System Image. For full device specs and more information about obtaining an Android Dev
-Phone 1 device, see the Android
-Market site. If you want a SIM-unlocked phone, then you might consider either an Android Dev Phone or the
+Google Nexus One. Both are SIM-unlocked so that you can use them on any GSM network using a SIM
+card. The Android Dev Phones also feature an unlocked bootloader so you can install custom system
+images (great for developing and installing custom versions of the Android platform). To purchase a
+Nexus One, visit google.com/phone. To purchase an Android
+Dev Phone, see the Android Market site
+(requires a developer account). Note: When developing on a device, keep in mind that you should
+still use the Android emulator to test your application
+on configurations that are not equivalent to those of your real device. Although the emulator
+does not allow you to test every device feature (such as the accelerometer), it does
+allow you to verify that your application functions properly on different versions of the Android
+platform, in different screen sizes and orientations, and more. With an Android-powered device, you can develop and debug your Android applications just as you
-would on the emulator. There are just a few things to do before you can start.In this document
-
Available Devices
-Consumer devices
-
-Android Dev Phone 1
-
-
-
-Setting up a Device for Development
In Eclipse, you can do this from the Application tab when viewing the Manifest @@ -159,37 +102,70 @@ href="#VendorIds">USB Vendor IDs, below.
You can verify that your device is connected by executing adb devices from your
-SDK tools/ directory. If connected, you'll see the device name listed as a "device."
If using Eclipse, select run or debug as usual. You will be presented -with a Device Chooser dialog that lists the available emulator(s) and connected device(s). -Select the device to install and run the application there.
-If using the Android Debug Bridge (adb), +
You can verify that your device is connected by executing adb devices from your
+SDK {@code tools/} directory. If connected, you'll see the device name listed as a "device."
If using Eclipse, run or debug as usual. You will be presented +with a Device Chooser dialog that lists the available emulator(s) and connected device(s). +Select the device upon which you want to install and run the application.
+ +If using the Android Debug Bridge (adb),
you can issue commands with the -d flag to target your
connected device.
This table provides a reference to the vendor IDs needed in order to add
-device support on Linux. The USB Vendor ID is the value given to the
-SYSFS{idVendor} property in the rules file.
SYSFS{idVendor} property in the rules file, as described in step 3, above.
+
| Manufacturer | USB Vendor ID |
|---|---|
| Acer | 0502 | Acer | +0502 |
| HTC | 0bb4 | Dell | +413c |
| Huawei | 12d1 | Foxconn | +0489 |
| LG | 1004 | Garmin-Asus | +091E |
| Motorola | 22b8 | HTC | +0bb4 |
| Samsung | 04e8 | Huawei | +12d1 |
| Sony Ericsson | 0fce | Kyocera | +0482 |
+
| LG | +1004 |
| Motorola | +22b8 |
| Nvidia | +0955 |
| Pantech | +10A9 |
| Samsung | +04e8 |
| Sharp | +04dd |
| Sony Ericsson | +0fce |
| ZTE | +19D2 |
Unless you know that you'll be using new APIs introduced in the latest SDK, you should - select a target with the lowest platform version possible, such as Android 1.1.
+ select a target with the lowest platform version possible.Note: You can change your the Build Target for your project at any time: Right-click the project in the Package Explorer, select Properties, select Android and then check @@ -89,7 +91,8 @@ Android project (or a project from existing code). To create a new project:
the minimum API Level required to properly run your application. Entering this here automatically sets theminSdkVersion attribute in the
<uses-sdk>
- of your Android Manifest file. If you're unsure of the appropriate API Level to use,
+ of your Android Manifest file. If you're unsure of the appropriate API Level to use,
copy the API Level listed for the Build Target you selected in the Target tab.
Before you can run your application on the Android Emulator, -you must create an Android Virtual Device (AVD). -An AVD is a configuration that specifies the Android platform to be used on the emulator. -You can read more in the Android Virtual -Devices document, but if you just want to get started, follow the simple guide below to -create an AVD.
+An Android Virtual Device (AVD) is a device configuration for the emulator that +allows you to model real world devices. In order to run an instance of the emulator, you must create +an AVD.
-If you will be running your applications only on actual device hardware, you do not -need an AVD — see -Developing On a Device for information -on running your application.
- -With ADT 0.9.3 and above, the Android SDK and AVD Manager provides a simple graphical interface
-for creating and managing AVDs. (If you're using ADT version 0.9.1 or older, you must
-use the android tool to create your AVDs—read the AVD guide to
-Creating an AVD.)
-
-
To create an AVD with the AVD Manager:
+To create an AVD from Eclipse:
Give it a name, a platform target, an SD card image (optional), and +
Give it a name, a platform target, an SD card size, and a skin (HVGA is default).
+Note: Be sure to define + a target for your AVD that satisfies your application's Build Target (the AVD + platform target must have an API Level equal to or greater than the API Level that your +application compiles against).
Your AVD is now ready and you can close the AVD Manager. -In the next section, you'll see how the AVD is used -when launching your application on an emulator.
+Your AVD is now ready and you can either close the SDK and AVD Manager, create more AVDs, or +launch an emulator with the AVD by selecting a device and clicking Start.
-For more information about AVDs, read the +
For more information about AVDs, read the Android Virtual Devices documentation.
-Note: Before you can run your application, be sure that -you have created an AVD with a target that satisfies your application's Build Target. -If an AVD cannot be found that meets the requirements of your Build Target, you will see -a console error telling you so and the launch will be aborted.
+Create multiple AVDs that each define a different device configuration with which your +application is compatible, then launch each AVD into a new emulator from the SDK and AVD Manager. +Set the target mode in your app's run configuration to manual, so that when you run your +application, you can select from the available virtual devices.
+To run (or debug) your application, select Run > Run (or -Run > Debug) from the Eclipse main menu. The ADT plugin -will automatically create a default launch configuration for the project.
+Running your application from Eclipse will usually require just a couple clicks, whether you're +running it on the emulator or on an attached device. The information below describes how to get +set up and run your application from Eclipse.
-When you choose to run or debug your application, Eclipse will perform the following:
+Before you can run your application on the Android Emulator, +you must create an AVD.
+ +To run (or debug) your application, select Run > Run (or +Run > Debug) from the Eclipse menu bar. The ADT plugin +will automatically create a default launch configuration for the project. Eclipse will then perform +the following:
By default, Android application run configurations use an "automatic target" mode for
- selecting a device target. For information on how automatic target mode selects a
- deployment target, see Automatic and manual
+ By default, Android run configurations use an "automatic target" mode for
+ selecting a device target. For information on how automatic target mode selects a
+ deployment target, see Automatic and manual
target modes below.
If debugging, the application will start in the "Waiting For Debugger" mode. Once the +
If debugging, the application will start in the "Waiting For Debugger" mode. Once the debugger is attached, Eclipse will open the Debug perspective.
-To set or change the launch configuration used for your project, use the launch configuration manager. +
To set or change the launch configuration used for your project, use the launch configuration +manager. See Creating a Launch Configuration for information.
+Be certain to create multiple AVDs upon which to test your application. You should have one AVD +for each platform and screen type with which your application is compatible. For +instance, if your application compiles against the Android 1.5 (API Level 3) platform, you should +create an AVD for each platform equal to and greater than 1.5 and an AVD for each screen type you support, then test +your application on each one.
+ + +Before you can run your application on a device, you must perform some basic setup for your +device:
+ +Read Setting up a Device for +Development for more information.
+ +Once set up and your device is connected via USB, install your application on the device by +selecting Run > Run (or +Run > Debug) from the Eclipse menu bar.
+ +The run configuration specifies the project to run, the Activity -to start, the emulator options to use, and so on. When you first run a project +to start, the emulator or connected device to use, and so on. When you first run a project as an Android Application, ADT will automatically create a run configuration. The default run configuration will launch the default project Activity and use automatic target mode for device selection @@ -240,7 +273,8 @@ for your Eclipse version:
By default, a run configuration uses the automatic target mode in order to select +
By default, a run configuration uses the automatic target mode in order to +select an AVD. In this mode, ADT will select an AVD for the application in the following manner:
android.os.Debug.startMethodTracing() will
start dmTrace.
-Open a code execution window, select Window>Show - View>Display from the main menu to open the +
Open a code execution window, select Window > Show + View > Display from the main menu to open the Display window, a simple text editor. Type your expression, highlight the text, and click the 'J' icon (or CTRL + SHIFT + D) to run your code. The code runs in the context of the selected thread, which must be diff --git a/docs/html/guide/developing/other-ide.jd b/docs/html/guide/developing/other-ide.jd index d043a7d5a2d7b..76b2d9ff8b0a8 100644 --- a/docs/html/guide/developing/other-ide.jd +++ b/docs/html/guide/developing/other-ide.jd @@ -13,7 +13,13 @@ page.title=Developing In Other IDEs
android list targets.
- name is the name for your project. This is optional. If provided, this name will be used
+ name is the name for your project. This is optional. If provided, this name will
+be used
for your .apk filename when you build your application.path is the location of your project directory. If the directory does not exist,
it will be created for you.activity is the name for your default {@link android.app.Activity} class. This class file
+ activity is the name for your default {@link android.app.Activity} class. This
+class file
will be created for you inside
- <path_to_your_project>/src/<your_package_namespace_path>/.
+
+<path_to_your_project>/src/<your_package_namespace_path>/
+.
This will also be used for your .apk filename unless you provide a the name.package is the package namespace for your project, following the same rules as for
+ package is the package namespace for your project, following the same rules as
+for
packages in the Java programming language.build.xml - Build file for Ant.default.properties - Properties for the build system. Do not modify
this file.build.properties - Customizable properties for the build system. You can edit this
- file to override default build settings used by Ant and provide a pointer to your keystore and key alias
+ build.properties - Customizable properties for the build system. You can edit
+this
+ file to override default build settings used by Ant and provide a pointer to your keystore and key
+alias
so that the build tools can sign your application when built in release mode.src/your/package/namespace/ActivityName.java - The Activity class
you specified during project creation.bin/ - Output directory for the build script.gen/ - Holds Ant-generated files, such as R.java. gen/ - Holds Ant-generated files, such as R.java.
+libs/ - Holds private libraries.res/ - Holds project resources.src/ - Holds source code.To update an existing Android project, open a command-line
and navigate to the tools/ directory of your SDK. Now run:
-android update project --name <project_name> --target <target_ID> --path path/to/your/project/ +android update project --name <project_name> --target <target_ID> +--path <path_to_your_project>
target is the "build target" for your application. It corresponds to
an Android platform library (including any add-ons, such as Google APIs) that you would
- like to build your project against. To see a list of available targets and their corresponding IDs,
+ like to build your project against. To see a list of available targets and their corresponding
+IDs,
execute: android list targets.path is the location of your project directory.name is the name for the project. This is optional—if you're not
@@ -218,7 +234,8 @@ or device.
Whether you're building in debug mode or release mode, you need to use the Ant tool to compile and build your project. This will create the .apk file that is installed onto the emulator or device. When you build in debug mode, the .apk -file is automatically signed by the SDK tools with a debug key, so it's instantly ready for installation +file is automatically signed by the SDK tools with a debug key, so it's instantly ready for +installation (but only onto an emulator or attached development device). When you build in release mode, the .apk file is unsigned, so you must manually sign it with your own private key, using Keytool and Jarsigner.
@@ -239,7 +256,7 @@ 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:\Progra~1\Java\. The easiest solution, however, is to
+set JAVA_HOME=c:\Progra~1\Java\<jdkdir>. The easiest solution, however, is to
install JDK in a non-space directory, for example: c:\java\jdk1.6.0_02.
Caution: Due to the way Ant handles input, the password that you enter during the build process will be visible. If you are concerned about your keystore and alias password being visible on screen, then you -may prefer to perform the application signing manually, via Jarsigner (or a similar tool). To instead -perform the signing procedure manually, buid unsigned and then continue +may prefer to perform the application signing manually, via Jarsigner (or a similar tool). To +instead +perform the signing procedure manually, build unsigned and then +continue with Signing Your Applications.
To specify your keystore and alias, open the project {@code build.properties} file (found in the @@ -366,87 +385,125 @@ download the application and begin installation. (On your device, be sure you have enabled Settings > Applications > Unknown sources.)
-Unless you'll be running your application on device hardware, -you need to launch an emulator upon which you will install your application. -An instance of the Android emulator runs a specific Android platform with specific device configuration -settings. The platform and configuration is defined with an Android Virtual Device (AVD). -So before you can launch your emulator, you must define an AVD.
+An Android Virtual Device (AVD) is a device configuration for the emulator that +allows you to model real world devices. In order to run an instance of the emulator, you must create +an AVD.
-If you'll be running your application on device hardware, please read about -Developing On a Device instead.
+To create an AVD using the SDK tools:
tools/ directory.android list targets-
This will output a list of available Android targets, such as:
--id:1 - Name: Android 1.1 - Type: platform - API level: 2 - Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P -id:2 - Name: Android 1.5 - Type: platform - API level: 3 - Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P --
Find the target that matches the Android platform upon which you'd like
- to run your application. Note the integer value of the id —
- you'll use this in the next step.
android create avd --name <your_avd_name> --target <target_ID>-
tools/ directory and execute the {@code android}
+tool with no arguments:
+ android+
This will launch the SDK and AVD Manager GUI.
+Give it a name, a platform target, an SD card size, and + a skin (HVGA is default).
+Note: Be sure to define + a target for your AVD that satisfies your application's build target (the AVD + platform target must have an API Level equal to or greater than the API Level that your +application compiles against).
+Your AVD is now ready and you can either close the AVD Manager, create more AVDs, or +launch an emulator with the AVD by clicking Start.
+ +For more information about AVDs, read the +Android Virtual Devices +documentation.
+ + +Create multiple AVDs that each define a different device configuration with which your +application is compatible, then launch each AVD into a new emulator from the SDK and AVD Manager. +Set the target mode in your app's run configuration to manual, so that when you run your +application, you can select from the available virtual devices.
+Running your application on a virtual or real device takes just a couple steps. Remember to +first build your application.
+ +Before you can run your application on the Android Emulator, +you must create an AVD.
+ +To run your application:
+From your SDK's tools/ directory, execute the {@code android} tool with no
+arguments:
+
android+
In the Virtual Devices view, select an AVD and click Start.
-From your SDK's tools/ directory, launch an emulator
- using an existing AVD (created above):
-
emulator -avd <your_avd_name>-
An instance of the emulator will now launch, running the target and configuration - defined by your AVD.
- -From your SDK's tools/ directory, install the .apk on the emulator:
-
adb install /path/to/your/application.apk-
If there is more than one emulator running, you must specify the emulator upon which to install
- the application, by its serial number, with the -s option. For example:
adb -s emulator-5554 install /my/project/path/myapp.apk-
In the emulator, open the list of available applications to find - and open your application.
+From your SDK's tools/ directory, install the {@code .apk} on the
+emulator:
+
adb install <path_to_your_bin>.apk+
Your APK file (signed with either a release or debug key) is in your project {@code bin/} +directory after you build your application.
+If there is more than one emulator running, you must specify the emulator upon which to
+install the application, by its serial number, with the -s option. For example:
adb -s emulator-5554 install /path/to/your/app.apk+
To see a list of available device serial numbers, execute {@code adb devices}.
If you don't see your application on the emulator. Try restarting the emulator -(with the same AVD). Sometimes when you install an Activity for the +
If you don't see your application on the emulator. Try closing the emulator and launching the +virtual device again from the SDK and AVD Manager. Sometimes when you install an Activity for the first time, it won't show up in the application launcher or be accessible by other applications. This is because the package manager usually examines manifests completely only on emulator startup.
-Tip: If you have only one emulator running, +
Be certain to create multiple AVDs upon which to test your application. You should have one AVD +for each platform and screen type with which your application is compatible. For +instance, if your application compiles against the Android 1.5 (API Level 3) platform, you should +create an AVD for each platform equal to and greater than 1.5 and an AVD for each screen type you support, then test +your application on each one.
+ +Tip: If you have only one emulator running,
you can build your application and install it on the emulator in one simple step.
Navigate to the root of your project directory and use Ant to compile the project
with install mode:
-ant install. This will build your application, sign it with the debug key,
-and install it on the currently running emulator.
-If there is more than one emulator currently running
-when using the install command, it will fail — it can't select between the
-multiple emulators.
ant install. This will build your application, sign it with the debug key,
+and install it on the currently running emulator.
+
+
+Before you can run your application on a device, you must perform some basic setup for your +device:
+ +Read Setting up a Device for +Development for more information.
+ +Once your device is set up and connected via USB, navigate to your
+SDK's tools/ directory and install the .apk on the device:
+
adb -d install /path/to/your/app.apk+
The {@code -d} flag specifies that you want to use the attached device (in case you also +have an emulator running).
+ +For more information on the tools used above, please see the following documents:
<platform>/<platform>/Set up the Hello World application
Follow the Notepad tutorial