Android official Getting Started document [2] Run your app

Source: Internet
Author: User
Tags configuration settings home screen

Tagged with: Android Android app Android developer Android emulator Android Studio

Android official Getting Started document [2] Run your app

Running Your App
Run your application

This lesson teaches
1.Run on a Real Device
2.Run on the Emulator

You should also read
? Using Hardware Devices
? Managing AVDs with AVD Manager
? Managing Projects

This lesson teaches you
1. Running on real devices
2. Run in simulator

You should also read
? Using hardware devices
? Management of automatic vacuum deposition system and AVD management
? Manage projects

If you followed the previous lesson to create an Android project, it includes a default set of ' Hello World ' source files That immediately run the app.
If you follow the previous lesson to create an Android project, it includes the "Hello World" source file, which enables you to run the application default settings immediately.

How do you run the Your app depends on the things:whether you had a real device running Android and whether you ' re using Androi D Studio. This lesson shows what to install and run your app on a real device and on the Android emulator, and in both cases with Either Android Studio or the command line tools.
How you run your application depends on two things: whether you have a real device running Android and whether you are using Android Studio. This lesson shows you how to install and run your application on real devices and Android emulators, and in both cases, whether it's with Android studio or the command-line tool.

Run on a Real Device
Running on a real device

-------------------------------------------------- ------------------------------
If you had a device running Android, here's how to install and run your app.
If you have a device running Android, here's how to install and run your app.

Set up your device
Set up your device

1. Plug in your device to your development, with a USB cable. If you ' re developing on Windows, you might need to install the appropriate USB driver for your device. For help installing drivers, see the OEM USB drivers document.
1. Plug in your device development machine using a USB cable. If you are developing windows, you may need to install the appropriate USB driver for your device. To help install the driver, see OEM USB driver files.

2. Enable USB debugging on your device. ? On more devices running Android 3.2 or older, you can find the option under Settings > Applications > Development.
? On Android 4.0 and newer, it's in Settings > Developer options.
Note:on Android 4.2 and newer, Developer options are hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screens to find Developer options.
2. Enable USB debugging on the device. On the most devices running Android3.2 or above, you can find the options in Settings > Applications > Development.
? in Android4.0 and later, it is in Settings > Developer options.
Note: In Android4.2 and later, the developer options are hidden by default. Make it available, go to Settings > about phone and develop build number 7 times. Go back to the previous screen to find the developer's choice.

Run the app from Android Studio
Run an app in Android studio

1.Select One of your project ' s files and click Run from the toolbar.
1. Select one of the project's files and click Run from the toolbar.

2.In The Choose device window that appears, select the Choose a running Device radio button, select your device, and click Ok.
2. In the appear, select the Select Run Device radio button, select your device, then click OK to select the device's window.

Android Studio installs the app on your connected device and starts it.
Android Studio installs the app on the connected device and launches it.

Run the app from a command line
From the command-line application

1.Change directories to the root of your Android project and execute:ant debug
1. Change the directory to your Android project and the root cause of the execution: Ant debug


2.Make sure the Android SDK platform-tools/directory is included in your PATH environment variable, then EXECUTE:ADB ins Tall bin/myfirstapp-debug.apk
2. Make sure that the Android SDK Platform Tool/directory is contained in the PATH environment variable and then execute: adb install bin/myfirstapp-debug.apk

3.On your device, locate Myfirstapp and open it.
3. On your device, find the Myfirstapp and open it.

That's how you build and run your Android app on a device! To-start developing, continue to the next lesson.
That's how you build and run Android apps on your device! Start development and continue to the next lesson.

Run on the Emulator
Running on the emulator

-------------------------------------------------- ------------------------------

Whether you ' re using Android Studio or the "command line," To run your app on the emulator you need to first create a Andro ID Virtual Device (AVD). An AVD are a device configuration for the Android emulator this allows you to model a specific device.

Whether you are using Android Studio or on the command line, to run your application on the emulator, you need to first create an Android virtual device (AVD). An AVD is an Android simulator that allows you to configure the device to a specific device model.

Create an AVD creates an AVD



1.Launch the Android Virtual Device Manager:? In Android Studio, select Tools > Android > AvD Manager, or click the AvD Manager icon in the toolbar.
? Or, from the command line, change directories to <sdk>/tools/and execute:android AVD
Note:the AVD Manager that appears if launched from the command line was different from the version of Android Studio so The following instructions may not apply.
1. Launch Android virtual Device Manager:? Inandroid Studio, select Tools>android > AvD Manager, or click the AvD Manager icon on the toolbar.
Or, on the command line, change the directory to <sdk>/tool/and execute: Android AVD
Note: When you start the command line, the AVD manager appears differently from the version in Android Studio, so the following instructions may not apply.

Figure 1. The AVD Manager main screen shows your current virtual devices.
Figure 1. Your current virtual device is displayed on the AVD Manager home screen.

2.On the AVD Manager main screen (Figure 1), click Create Virtual Device.
2. In the AVD Manager main interface (Figure 1), click Create Virtual device.

3.In the Select Hardware window, select a device configuration, such as Nexus 6, then click Next.
3. In the Select Hardware window, select a device configuration, such as Nexus 6, and then click Next.

4.Select the desired system version for the AVD and click Next.
4. Select the desired system version for AVD, and then click Next.

5.Verify the configuration settings, then click Finish.
5. Verify the configuration settings and click Finish.

For more information on using AVDs, see Managing AVDs with AVD Manager.
For more information on the use of automated vacuum deposition systems, see Managing automated vacuum deposition systems with the AVD manager.

Run the app from Android Studio
Run an app in Android studio

1.In Android Studio, select your project and click Run from the toolbar.
1. In Android Studio, select your project and click Run from the toolbar.

2.In the Choose Device window, click the Launch Emulator radio button.
2. In the Select a Device window, click the Launch Simulator radio button.

3.From the Android virtual device pull-down menu, select the emulator you created, and click OK.
3. From the Android virtual device drop-down menu, select the emulator that you created, and then click OK.

It can take a few minutes for the emulator to load itself. Unlock the screen. When you do, My first App is appears on the emulator screen.
It may take a few minutes for the emulator to load itself. You may need to unlock the screen. When you do this, my first application appears on the emulator screen.


Run your app from the command line
Run your application from the command line

1.Change directories to the root of your Android project and execute:ant debug
1. Change the directory to your Android project and the root cause of the execution: Ant debug

2.Make sure the Android SDK platform-tools/directory is included in your PATH environment variable, then EXECUTE:ADB ins Tall bin/myfirstapp-debug.apk
2. Make sure that the Android SDK Platform Tool/directory is contained in the PATH environment variable and then execute: adb install bin/myfirstapp-debug.apk

3.On the emulator, locate Myfirstapp and open it.
3. On the emulator, locate the Myfirstapp and open it.

That's how to build and run your Android app on the emulator! To-start developing, continue to the next lesson.
This is how you build and run Android apps on the emulator! Start development and continue to the next lesson.

This article is translated from: https://developer.android.com/training/basics/firstapp/running-app.html

Android official Getting Started document [2] running your application

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.