2.运行你的App-Google官网上的Android初学训练
2015-12-06 23:02
591 查看
原文地址:http://developer.android.com/training/basics/firstapp/running-app.html
真实设备上运行
如果有运行着Android的设备, 下面是如何安装并运行app.设置你的设备
USB cable将设备连上计算机。在设备上开启 USB debugging。
在老版本Android设备上,此选项在 Settings > Applications > Development.
在 Android 4.0 以上版本, 此选项在 Settings > Developer options.
Note: On Android 4.2 and newer, Developer options is hidden by default. To make it available, go toSettings > About phone and tap Build number seven times. Return to the previous screen to
findDeveloper options.
从 Android Studio运行app
选择任一项目文件,从工具栏点击 Run.
在 Choose Device , 选择 Choose a running device , 选择你的设备, 点击 OK .
Android Studio 把app安装到你连接的设备并运行app.
从命令行运行app
打开命令行并定位到项目根目录. 使用Gradle 在debug模式构建项目, 调用assembleDebug
将创建
.apk文件,此文件生成到
build/目录, 名为
MyFirstApp-debug.apk.
在Windows平台,输入以下命令:
> gradlew.bat assembleDebug
在Mac OS 和 Linux 平台, 输入以下命令:
$ chmod +x gradlew $ ./gradlew assembleDebug
生成的app位于
app/build/outputs/apk/
确保 Android SDK
platform-tools/路径包含在你的
PATH环境变量里, 然后执行:
adb install app/build/outputs/MyFirstApp-debug.apk
在设备上, 找到 MyFirstApp 打开.
这是如何在设备上运行,继续学习开发请查看 next
lesson.
模拟器上运行
首先要创建 AndroidVirtual Device (AVD). AVD是指定模拟器的配置信息。
创建 AVD
加载 Android Virtual Device Manager:在 Android Studio, 选择 Tools > Android > AVD Manager, 点击
.
或者, 从命令行, 定位到
sdk/执行:
tools/android avd
Figure 1. The AVD Manager main screen shows your current virtual devices.
在 AVD Manager 主界面 (figure 1), 点击Create Virtual Device.
在选择硬件窗口, 选择一个设备配置, 例如 Nexus 6, 然后点击 Next.
选择 AVD的sdk版本,点击 Next.
确认配置无误,点击 Finish.
更多信息请查看 Managing
AVDs with AVD Manager.
相关文章推荐
- Android实践项目汇报(总结)
- Android图片加载(二)--妹子图客户端改进
- Android自定义TextView省略号样式
- Android常用权限
- 编译错误jni/Android.mk:12: *** commands commence before first targe
- 1.创建Android项目-Google官网上的Android初学训练
- 自定义模拟+数字时钟,整合AnalogDigitalView
- Android Studio apk 打包流程
- OTG – Android USB Hos
- Android图片处理神器BitmapFun源码分析
- 从代码分析Android-Universal-Image-Loader的图片加载、显示流程
- Android从源码分析一:Looper,Handler消息机制
- Android Studio编译提速方法
- Android fork
- Android 初探OverScroller
- Android 实践项目开发 总结
- Android Support Design之Snackbar
- 自定义ChronometerView实现类似秒表倒计时,短信验证码倒计时功能
- Android编程
- Android自定义ProgressDialog