本文共 4050 字,大约阅读时间需要 13 分钟。
How you run your app depends on two things: whether you have a real Android-powered device and whether you're using Eclipse. This lesson shows you how to install and run your app on a real device and on the Android emulator, and in both cases with either Eclipse or the command line tools.
Before you run your app, you should be aware of a few directories and files in the Android project:
AndroidManifest.xml
src/
class that runs when your app is launched using the app icon. res/
drawable-hdpi/
layout/
values/
When you build and run the default Android app, the default class starts and loads a layout file that says "Hello World." The result is nothing exciting, but it's important that you understand how to run your app before you start developing.
If you have a real Android-powered device, here's how you can install and run your app:
Note: On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.
To run the app from Eclipse, open one of your project's files and click Run from the toolbar. Eclipse installs the app on your connected device and starts it.
Or to run your app from a command line:
ant debug
platform-tools/
directory is included in your PATH
environment variable, then execute: adb install bin/MyFirstApp-debug.apk
That's how you build and run your Android app on a device! To start developing, continue to the .
Whether you're using Eclipse or the command line, to run your app on the emulator you need to first create an (AVD). An AVD is a device configuration for the Android emulator that allows you to model different devices.
To create an AVD:
<sdk>/tools/
and execute: android avd
To run the app from Eclipse, open one of your project's files and click Run from the toolbar. Eclipse installs the app on your AVD and starts it.
Or to run your app from the command line:
ant debug
platform-tools/
directory is included in your PATH
environment variable, then execute: adb install bin/MyFirstApp-debug.apk
转载地址:http://rtgdi.baihongyu.com/