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

目录
相关文章
|
6月前
|
存储 消息中间件 人工智能
【03】AI辅助编程完整的安卓二次商业实战-本地构建运行并且调试-二次开发改注册登陆按钮颜色以及整体资源结构熟悉-优雅草伊凡
【03】AI辅助编程完整的安卓二次商业实战-本地构建运行并且调试-二次开发改注册登陆按钮颜色以及整体资源结构熟悉-优雅草伊凡
232 3
|
11月前
|
存储 Android开发
如何查看Flutter应用在Android设备上已被撤销的权限?
如何查看Flutter应用在Android设备上已被撤销的权限?
569 64
|
6月前
|
存储 API Android开发
【02】完整的安卓二次商业实战-配置gradle-构建打包原生安卓项目-调试本地运行模拟器-优雅草伊凡
【02】完整的安卓二次商业实战-配置gradle-构建打包原生安卓项目-调试本地运行模拟器-优雅草伊凡
518 4
【02】完整的安卓二次商业实战-配置gradle-构建打包原生安卓项目-调试本地运行模拟器-优雅草伊凡
|
11月前
|
存储 Android开发 数据安全/隐私保护
如何在Android设备上撤销Flutter应用程序的所有权限?
如何在Android设备上撤销Flutter应用程序的所有权限?
723 64
|
11月前
|
缓存 Android开发 开发者
Flutter环境配置完成后,如何在Android设备上运行Flutter应用程序?
Flutter环境配置完成后,如何在Android设备上运行Flutter应用程序?
2064 62
|
11月前
|
开发工具 Android开发 开发者
在Android设备上运行Flutter应用程序时,如果遇到设备未授权的问题该如何解决?
在Android设备上运行Flutter应用程序时,如果遇到设备未授权的问题该如何解决?
774 61
|
8月前
|
存储 Android开发 数据安全/隐私保护
Thanox安卓系统增加工具下载,管理、阻止、限制后台每个APP运行情况
Thanox是一款Android系统管理工具,专注于权限、后台启动及运行管理。支持应用冻结、系统优化、UI自定义和模块管理,基于Xposed框架开发,安全可靠且开源免费,兼容Android 6.0及以上版本。
996 4
|
前端开发 Java Shell
【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
851 20
【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
|
缓存 Java 测试技术
【01】噩梦终结flutter配安卓android鸿蒙harmonyOS 以及next调试环境配鸿蒙和ios真机调试环境-flutter项目安卓环境配置-gradle-agp-ndkVersion模拟器运行真机测试环境-本地环境搭建-如何快速搭建android本地运行环境-优雅草卓伊凡-很多人在这步就被难倒了
【01】噩梦终结flutter配安卓android鸿蒙harmonyOS 以及next调试环境配鸿蒙和ios真机调试环境-flutter项目安卓环境配置-gradle-agp-ndkVersion模拟器运行真机测试环境-本地环境搭建-如何快速搭建android本地运行环境-优雅草卓伊凡-很多人在这步就被难倒了
1829 3
【01】噩梦终结flutter配安卓android鸿蒙harmonyOS 以及next调试环境配鸿蒙和ios真机调试环境-flutter项目安卓环境配置-gradle-agp-ndkVersion模拟器运行真机测试环境-本地环境搭建-如何快速搭建android本地运行环境-优雅草卓伊凡-很多人在这步就被难倒了
|
Dart 前端开发 Android开发
【09】flutter首页进行了完善-采用android studio 进行真机调试开发-增加了直播间列表和短视频人物列表-增加了用户中心-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
【09】flutter首页进行了完善-采用android studio 进行真机调试开发-增加了直播间列表和短视频人物列表-增加了用户中心-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
420 4
【09】flutter首页进行了完善-采用android studio 进行真机调试开发-增加了直播间列表和短视频人物列表-增加了用户中心-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex

热门文章

最新文章