Android官方入门文档[2]运行你的应用程序

简介: Android官方入门文档[2]运行你的应用程序 Running Your App运行你的应用程序 This lesson teaches you to1.

Android官方入门文档[2]运行你的应用程序

 

Running Your App
运行你的应用程序

 

This lesson teaches you to
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

这节课教你
1.运行在真实设备
2.运行在模拟器

你也应该阅读
•使用硬件设备
•管理自动真空淀积系统与AVD管理
•管理项目

 

If you followed the previous lesson to create an Android project, it includes a default set of "Hello World" source files that allow you to immediately run the app.
如果按照以前的教训,以创建一个Android项目,它包括了“Hello World”的源文件,使您可以立即运行的应用程序默认设置。

How you run your app depends on two things: whether you have a real device running Android and whether you're using Android Studio. 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 Android Studio or the command line tools.
您如何运行你的应用程序取决于两件事情:你是否有运行Android以及是否正在使用Android Studio中的真实设备。本课向您展示如何安装和在真实的设备和Android模拟器上运行你的应用程序,并在这两种情况下,无论是与Android Studio或命令行工具。

 

Run on a Real Device
在真实设备上运行

 

-------------------------------------------------- ------------------------------
If you have a device running Android, here's how to install and run your app.
如果您有运行Android的设备,这里是如何安装和运行你的应用程序。

 

Set up your device
设置设备

 

1. Plug in your device to your development machine 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.插入您的设备开发机器使用USB电缆。如果您正在开发Windows上,您可能需要安装相应的USB驱动程序为您的设备。为了帮助安装驱动程序,请参阅OEM USB驱动程序文件。

2. Enable USB debugging on your device. ◦On most 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 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.
2.启用USB调试设备上。 ◦On运行Android3.2或以上的大多数设备,你可以找到在设置>应用程序>开发的选项。
◦在Android4.0及更高版本,它在设置>开发者选项。
注意:在Android4.2及更高版本,开发者选项默认是隐藏的。使其可用,进入设置>关于手机和开发内部版本号7次。返回到上一画面找到开发者的选择。

 

Run the app from Android Studio
运行Android Studio中的应用

 

1.Select one of your project's files and click Run  from the toolbar.
1.选择项目的文件之一,然后点击运行从工具栏。

2.In the Choose Device window that appears, select the Choose a running device radio button, select your device, and click OK .
2.在出现,选择选择运行设备单选按钮,选择您的设备,然后点击确定选择设备的窗口。

Android Studio installs the app on your connected device and starts it.
Android Studio安装连接的设备上的应用程序,并启动它。

 

Run the app from a command line
从命令行应用程序

 

1.Change directories to the root of your Android project and execute: ant debug
1.更改目录到你的Android项目和执行的根源:ant debug


2.Make sure the Android SDK platform-tools/ directory is included in your PATH environment variable, then execute: adb install bin/MyFirstApp-debug.apk
2.确保在Android SDK平台工具/目录包含在PATH环境变量,然后执行:adb install bin/MyFirstApp-debug.apk

3.On your device, locate MyFirstApp and open it.
3.在你的设备上,找到MyFirstApp并打开它。

That's how you build and run your Android app on a device! To start developing, continue to the next lesson.
这就是你如何建立和设备上运行Android应用程序!开始开发,继续下一课。

 

Run 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 an Android Virtual Device (AVD). An AVD is a device configuration for the Android emulator that allows you to model a specific device.

无论你使用的是Android Studio或在命令行中,要在模拟器上运行你的应用程序,你需要首先创建一个Android虚拟设备(AVD)。一个AVD是Android模拟器,可以让你到一个特定的设备型号的设备的配置。

 

Create an AVD

创建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 when launched from the command line is different from the version in Android Studio, so the following instructions may not apply.
1.启动Android虚拟设备管理器:◦InAndroid Studio,选择Tools>Android > AVD管理器,或单击工具栏上的AVD管理器图标。
◦或者,在命令行,将目录更改为<SDK>/工具/并执行:Android的AVD
注:在命令行启动时,将出现AVD管理器是从Android Studio中的版本不同,所以下面的说明可能不适用。
 
Figure 1. The AVD Manager main screen shows your current virtual devices.
图1. AVD管理器主屏幕上显示您当前的虚拟设备。

2.On the AVD Manager main screen (figure 1), click Create Virtual Device.
2.在AVD管理器主界面(图1),单击创建虚拟设备。

3.In the Select Hardware window, select a device configuration, such as Nexus 6, then click Next.
3.在选择硬件窗口中,选择一个设备配置,如Nexus的6,然后单击下一步。

4.Select the desired system version for the AVD and click Next.
4.选择所需的系统版本为AVD,然后单击下一步。

5.Verify the configuration settings, then click Finish.
5.验证配置设置,然后单击完成。

For more information about using AVDs, see Managing AVDs with AVD Manager.
有关使用自动真空淀积系统的更多信息,请参阅管理自动真空淀积系统与AVD管理器。

 

Run the app from Android Studio
运行Android Studio中的应用

 

1.In Android Studio, select your project and click Run  from the toolbar.
1.在Android Studio中,选择你的项目,点击运行从工具栏。

2.In the Choose Device window, click the Launch emulator radio button.
2.在选择设备窗口中,单击启动模拟器单选按钮。

3.From the Android virtual device pull-down menu, select the emulator you created, and click OK.
3.从Android 虚拟设备下拉菜单中,选择您创建的仿真器,然后单击确定。

 

It can take a few minutes for the emulator to load itself. You may have to unlock the screen. When you do, My First App appears on the emulator screen.
它可能需要几分钟的模拟器来加载自身。您可能需要解锁屏幕。当你这样做,我的第一个应用程序出现在仿真器屏幕上。


Run your app from the command line
在命令行中运行你的应用程序

 

1.Change directories to the root of your Android project and execute: ant debug
1.更改目录到你的Android项目和执行的根源:ant debug

2.Make sure the Android SDK platform-tools/ directory is included in your PATH environment variable, then execute: adb install bin/MyFirstApp-debug.apk
2.确保在Android SDK平台工具/目录包含在PATH环境变量,然后执行:adb install bin/MyFirstApp-debug.apk

3.On the emulator, locate MyFirstApp and open it.
3.在模拟器上,找到MyFirstApp并打开它。

That's how you build and run your Android app on the emulator! To start developing, continue to the next lesson.
这就是你如何建立并在模拟器上运行Android应用程序!开始开发,继续下一课。

本文翻译自:https://developer.android.com/training/basics/firstapp/running-app.html

目录
相关文章
|
22天前
|
移动开发 Java Android开发
构建高效Android应用:探究Kotlin与Java的性能差异
【4月更文挑战第3天】在移动开发领域,性能优化一直是开发者关注的焦点。随着Kotlin的兴起,其在Android开发中的地位逐渐上升,但关于其与Java在性能方面的对比,尚无明确共识。本文通过深入分析并结合实际测试数据,探讨了Kotlin与Java在Android平台上的性能表现,揭示了在不同场景下两者的差异及其对应用性能的潜在影响,为开发者在选择编程语言时提供参考依据。
|
23天前
|
数据库 Android开发 开发者
构建高效Android应用:Kotlin协程的实践指南
【4月更文挑战第2天】随着移动应用开发的不断进步,开发者们寻求更流畅、高效的用户体验。在Android平台上,Kotlin语言凭借其简洁性和功能性赢得了开发社区的广泛支持。特别是Kotlin协程,作为一种轻量级的并发处理方案,使得异步编程变得更加简单和直观。本文将深入探讨Kotlin协程的核心概念、使用场景以及如何将其应用于Android开发中,以提高应用性能和响应能力。通过实际案例分析,我们将展示协程如何简化复杂任务,优化资源管理,并为最终用户提供更加流畅的体验。
|
23天前
|
开发框架 安全 Android开发
探索安卓系统的新趋势:智能家居应用的蓬勃发展
随着智能家居概念的兴起,安卓系统在智能家居应用领域的应用日益广泛。本文将探讨安卓系统在智能家居应用开发方面的最新趋势和创新,以及其对用户生活的影响。
14 2
|
26天前
|
缓存 监控 Java
构建高效Android应用:从优化用户体验到提升性能
在竞争激烈的移动应用市场中,为用户提供流畅和高效的体验是至关重要的。本文深入探讨了如何通过多种技术手段来优化Android应用的性能,包括UI响应性、内存管理和多线程处理。同时,我们还将讨论如何利用最新的Android框架和工具来诊断和解决性能瓶颈。通过实例分析和最佳实践,读者将能够理解并实施必要的优化策略,以确保他们的应用在保持响应迅速的同时,还能够有效地利用系统资源。
|
26天前
|
Java Android开发
Android 开发获取通知栏权限时会出现两个应用图标
Android 开发获取通知栏权限时会出现两个应用图标
12 0
|
1月前
|
编解码 算法 Java
构建高效的Android应用:内存优化策略详解
随着智能手机在日常生活和工作中的普及,用户对移动应用的性能要求越来越高。特别是对于Android开发者来说,理解并实践内存优化是提升应用程序性能的关键步骤。本文将深入探讨针对Android平台的内存管理机制,并提供一系列实用的内存优化技巧,以帮助开发者减少内存消耗,避免常见的内存泄漏问题,并确保应用的流畅运行。
|
24天前
|
Java Android开发 开发者
构建高效Android应用:Kotlin协程的实践与优化
在响应式编程范式日益盛行的今天,Kotlin协程作为一种轻量级的线程管理解决方案,为Android开发带来了性能和效率的双重提升。本文旨在探讨Kotlin协程的核心概念、实践方法及其在Android应用中的优化策略,帮助开发者构建更加流畅和高效的应用程序。通过深入分析协程的原理与应用场景,结合实际案例,本文将指导读者如何优雅地解决异步任务处理,避免阻塞UI线程,从而优化用户体验。
|
29天前
|
Java 编译器 Android开发
构建高效Android应用:探究Kotlin与Java的性能差异
在开发高性能的Android应用时,选择合适的编程语言至关重要。近年来,Kotlin因其简洁性和功能性受到开发者的青睐,但其性能是否与传统的Java相比有所不足?本文通过对比分析Kotlin与Java在Android平台上的运行效率,揭示二者在编译速度、运行时性能及资源消耗方面的具体差异,并探讨在实际项目中如何做出最佳选择。
17 4
|
1天前
|
移动开发 Java Android开发
构建高效Android应用:采用Kotlin协程优化网络请求
【4月更文挑战第24天】 在移动开发领域,尤其是对于Android平台而言,网络请求是一个不可或缺的功能。然而,随着用户对应用响应速度和稳定性要求的不断提高,传统的异步处理方式如回调地狱和RxJava已逐渐显示出局限性。本文将探讨如何利用Kotlin协程来简化异步代码,提升网络请求的效率和可读性。我们将深入分析协程的原理,并通过一个实际案例展示如何在Android应用中集成和优化网络请求。
|
1天前
|
调度 Android开发 开发者
构建高效Android应用:探究Kotlin协程的优势与实践
【4月更文挑战第24天】随着移动开发技术的不断演进,提升应用性能和用户体验已成为开发者的核心任务。在Android平台上,Kotlin语言凭借其简洁性和功能性成为主流选择之一。特别是Kotlin的协程功能,它为异步编程提供了一种轻量级的解决方案,使得处理并发任务更加高效和简洁。本文将深入探讨Kotlin协程在Android开发中的应用,通过实际案例分析协程如何优化应用性能,以及如何在项目中实现协程。