[Android training video series] 1.2 running your app

Source: Internet
Author: User

1. Main Content

This section describes how to run your applications on a real machine or simulator, including eclipse and command line.

2. Video description
Http://www.eyeandroid.com/thread-10673-1-1.html

3. Translation Reference

This section will teach you how

  • Run on a real device
  • Run on the emulator run the application on the VM

If you create an android project following the previous section, it contains a set of default "Hello World" source files that can be run correctly.

Running your application depends on two things: Whether you have a real Android-based device and whether you use eclipse. This section describes how to install and run applications on real devices or the andorid simulator, whether you are using eclipse or the command line tool.

Before running your application, you should know several directories and files in the android project.

  • Androidmanifest. xml
This manifest file describes the basic attributes of the application and defines each component in the application. You will learn more about the statements when learning more courses in the future.
  • Src/
This directory is the main directory of your source program. By default, a directory contains an activity class, which runs when you click the application icon.
  • Res/contains several subdirectories, which are application resource files. The following are examples:
Drawable-hdpi/
It stores the drawable objects (bitmaps image) designed for high-resolution (hdpi) screens ). Other drawable directories contain resources (images) designed for other resolutions ).
Layout/
The file in this directory is used to define the user interface of the application.
Values/
This directory contains XML files of various resource sets, such as the definition of strings and colors.

When you build and run the default Android project, the default activity class in the src directory starts to run and loads a layout file from the layout directory, the layout file contains a "hello World" message. Although not excited, it is very important for you to understand how to build and run applications before implementing truly functional applications.

Run on a real device

Whether you are using eclipse or the command line tool, you need:

  • 1. Use a USB cable to connect your Android device to your computer. If you are developing in Windows, you need to install the correct USB driver for the device. For more information about Driver Installation, see oem usb driver.
  • 2. Make sure that the "USB debug" option on the device is enabled (most of them are in "Settings"-> "application"-> "development" or "Developer options" in systems above 4.0 "medium ).

Run the application from eclipse, open a project file, and click Run in the toolbar. Eclipse will install the application to the device you are connected to and start running it.

Or you can run the application from the command line.

  • 1. Switch to the root directory of your android project and run:
ant debug
  • 2. The directory has been added to the "path" environment variable, and then run:
adb install bin/MyFirstApp-debug.apk
  • 3. Find myfirstactivity on your device and open it.

If you want to start adding something to the application, continue the course.

Run on the emulator run the application on the simulator

Whether you use eclipse or the command line tool, you must first create an android Virtual Device (AVD). AVD is an android Simulator for device configuration. It allows you to change the configurations of different devices.

 

Figure 1. AVD manager shows several virtual devices.

Create an AVD:

1. Open the android Virtual Device Manager:

A: In eclipse, select Window> AVD manager, or click the AVD manager icon on the toolbar.

B: In the command line, switch to the <SDK>/tools/directory and execute:

android avd

2. for Android AVD, click New on the android Virtual Device Manager panel.

3. Fill in AVD details, give it a name, and select the target platform, SD card capacity and screen size.

4. Click Create AVD.

5. In Android Virtual Device Manager, select the new AVD and click Start.

6. Unlock the simulator screen after the simulator starts.

Run the application from eclipse, open a project file, and click run on the toolbar. Eclipse will install the application to your AVD and run it.

Or run your application from the command line:

1. Switch to the root directory of the android project and run:

ant debug

2. Make sure that the android SDK platform-tools/directory is included in the PATH environment variable and then run:

adb install bin/MyFirstApp-debug.apk

3. In the simulator, locate myfirstactivity and open it.

Start to add something to the application. continue to the next lesson.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.