Android learning route (3) run your Android app, route android

Source: Internet
Author: User

Android learning route (3) run your Android app, route android

If you have created your Android project according to the previous lesson, it contains the default "Hello World" source file, allowing your project to run immediately.

How do you run your application? Two things: Whether you have a real Android device and whether you are using Eclipse. This course shows you how to use Eclipse and command line tools to install your application on a real machine and a simulator.

Before running your application, you must understand these directory files in the Android project:

AndroidManifest.xml
This manifest file describes the basic features of an application and its components. After learning more training courses, you will find that you can use multiple methods to define them in this document.

The<uses-sdk>Element. It usesandroid:minSdkVersionAndandroid:targetSdkVersionAttribute declares the compatibility of your application on different Android versions. In your first project, it should be like the following:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" ... >    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />    ...</manifest>

You should keep settingandroid:targetSdkVersionFor the latest version, and test on the corresponding version. For more information, see Supporting Different Platform Versions.

src/
The Directory of your application code. By default, it contains ActivityClass, which is run when your application is started through the icon.
res/
Contains subdirectories of some application resources. There is only one part here:
drawable-hdpi/
Directory for storing image resources on high-resolution screens. Other directories contain resources designed for other resolution screens.
layout/
The directory that stores the application user interface.
values/
Directory for storing multiple other XML files. These files contain a set of resources, such as string and color.

When you build and run the default Android Application, the defaultActivityClass, and load the layout file with "Hello World. Although this result is not very exciting, this example is very important for you to understand how to run an Android Application before development.

Run applications on a real machine

If you have an Android device, the following shows how to install and run applications on your device.

  1. Connect your device to the developed machine through USB. If you develop a driver in Windows, you may need to install a proper driver for your device. For how to install the driver, see the oem usb Drivers documentation.
  2. Enable USB debugging on your device.
    • In most Android 3.2 or older versions, you can useSettings> Application> DevelopmentTo find the corresponding options.
    • On Android 4.0 or an updated deviceSettings> developer options.

      Tip:On Android 4.0 or an updated device,Developer optionsIt is hidden by default. If you want to see it, you need to enterSettings> about mobile phoneAnd clickVersion NumberUnder 7. Then return to the previous interface and you will be able to seeDeveloper options.

Run applications through Eclipse

  1. Open a file in your project, and clickRun.
  2. InRunInterface, selectAndroid ApplicationThen clickOK.

Eclipse will install the application on the connected device and start the application.

Or start the application through the command line:

  1. In the command line, change the directory to the project root directory and then execute:
    ant debug
  2. Guaranteeplatform-tools/Already addedPATHEnvironment variable, and then execute:
    adb install bin/MyFirstApp-debug.apk
  3. Find on your deviceMyFirstActivityAnd open it.
Run on Simulator

Whether you are using Eclipse or the command line interface, to run your application on the simulator, you must first create an Android Virtual Device (AVD ). An AVD allows the Android simulator to simulate the configurations of different devices.

Figure 1. The AVD Manager showing a few virtual devices.

Create an AVD:

  1. Start the Android virtual device to manage it:
    1. In Eclipse, click Android virtual device management on the toolbar.
    2. In the command line, change the directory<sdk>/tools/Directory, and then execute:
      android avd
  2. On the Android virtual device management page, clickNew.
  3. Enter AVD details. Including its name, target version, SD card size, skin, etc.
  4. ClickCreate AVD.
  5. Select a new AVD and clickStart.
  6. Unlock the simulator after it is started.

Run the application through Eclipse.

  1. Open a file in your project, and clickRun.
  2. InRunInterface, selectAndroid ApplicationThen clickOK.

Eclipse will install the application on the connected simulator and start the application.

Or start the application through the command line:

  1. In the command line, change the directory to the project root directory and then execute:
    ant debug
  2. Guaranteeplatform-tools/Already addedPATHEnvironment variable, and then execute:
    adb install bin/MyFirstApp-debug.apk
  3. FindMyFirstActivityAnd open it.



Android learning route

If java is done, it will be easier for android to learn.
Android BASICS (debugging in the Android development environment, Android Application structure, interface components and interface programming, and four main components)
Android intermediate (file IO and SQLite, graphics, images and animations, audio and video recording for playback, sensor programming, and GPS applications)
Android advanced (Network Programming and Web Service, OpenGL-ES 3D development, integration of Google services, using NDK development, java and c mutual calls)

Having a solid Java Foundation, learning the specific learning path of Android and learning videos and books of Android?

See if you want this? Other android documents can be downloaded from websites such as csdn.


Related Article

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.