前面的内容请参见Android应用自动化测试-提纲。 本篇我们介绍在Android SDK中另一个重要的命令,Android命令。android命令主要是操作sdk相关的一些指令

android sdk/avd

Android sdk命令用于打开sdk manager的窗口界面

android update sdk命令用于更新当前的sdk

android avd用于打开avd manager的窗口界面

android list

这个命令可以用来列出当前设备上android主要组件的信息. 如果只需要看到基本信息,可以加上-c参数

android list devices

这里不是像adb devices那样列出当前连接的设备,而是列出当前设备上可用的模拟设备镜像类型,如:

> android list devices -c

tv_1080ptv_720pwear_roundwear_round_chin_320_290wear_squareGalaxy NexusNexus 10Nexus 4Nexus 5Nexus 6Nexus 7 2013Nexus 7Nexus 9Nexus OneNexus S2.7in QVGA2.7in QVGA slider3.2in HVGA slider (ADP1)3.2in QVGA (ADP2)3.3in WQVGA3.4in WQVGA3.7 FWVGA slider3.7in WVGA (Nexus One)4in WVGA (Nexus S)4.65in 720p (Galaxy Nexus)4.7in WXGA5.1in WVGA5.4in FWVGA7in WSVGA (Tablet)10.1in WXGA (Tablet)

android list target

这个命令用于列出当前设备上的android sdk API版本

>android list target

 Available Android targets: ---------- id: 1 or "android-10"      Name: Android 2.3.3      Type: Platform      API level: 10      Revision: 2      Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854  Tag/ABIs : default/armeabi, default/x86 ---------- id: 2 or "android-17"      Name: Android 4.2.2      Type: Platform      API level: 17      Revision: 3      Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in  Tag/ABIs : default/x86 ---------- id: 3 or "android-23"      Name: Android 6.0      Type: Platform      API level: 23      Revision: 3      Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in  Tag/ABIs : default/x86_64 ---------- id: 4 or "android-24"      Name: Android 7.0      Type: Platform      API level: 24      Revision: 2      Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in  Tag/ABIs : default/arm64-v8a, default/x86_64

需要注意这个target ID,在我们后面自动化测试时,指定对应的android api版本时需要经常用到

android list avd

这个命令用于列出当前已经创建的android模拟器

android list sdk

这个命令用于列出目前sdk的可用包清单

AVD相关

通过android命令,可以在命令行中实现虚机的创建、销毁等操作。这对于我们自动化时动态管理模拟器是非常有用的

android create avd

Options:
-t --target : Target ID of the new AVD. [required]
-a --snapshot: Place a snapshots file in the AVD, to enable persistence.
-c --sdcard : Path to a shared SD card image, or size of a new sdcard for
the new AVD.
-p --path : Directory where the new AVD will be created.
-b --abi : The ABI to use for the AVD. The default is to auto-select the
ABI if the platform has only one ABI for its system images.
-d --device : The optional device definition to use. Can be a device index
or id.
-n --name : Name of the new AVD. [required]
-s --skin : Skin for the new AVD.
-g --tag : The sys-img tag to use for the AVD. The default is to
auto-select if the platform has only one tag for its system
images.
-f --force : Forces creation (overwrites an existing AVD)

如:

>android create avd -t 1 -n avd233 -b x86

 Android 2.3.3 is a basic Android platform. Do you wish to create a custom hardware profile [no] Created AVD 'avd233' based on Android 2.3.3, Intel Atom (x86) processor, with the following hardware config: hw.lcd.density=240 hw.ramSize=256 vm.heapSize=24

project相关

android命令的另一个重要功能是可以通过命令行直接创建android应用项目以及测试项目

android create project

Options:
-n --name : Project name.
-a --activity : Name of the default Activity that is created.
[required]
-k --package : Android package name for the application. [required]
-v --gradle-version: Gradle Android plugin version.
-t --target : Target ID of the new project. [required]
-g --gradle : Use gradle template.
-p --path : The new project's directory. [required]

android create test-project

Options:
-m --main : Path to directory of the app under test, relative to the test
project directory. [required]
-p --path : The new project's directory. [required]
-n --name : Project name.

android create uitest-project

Options:
-n --name : Project name.
-p --path : The new project's directory. [required]
-t --target : Target ID of the new project. [required]

更多相关文章

  1. Android命令行启动程序-am命令的使用-纠正网上大部分资料的错误
  2. Android中的Interpolator
  3. 在 Android(安卓)模拟器中安装 busybox
  4. Android一些学习的小点
  5. 关于android的各种disk images
  6. 一定是我打开的姿势不对——Android下使用kill命令杀死指定进程
  7. Android应用程序中执行二进制命令
  8. Android(安卓)SDK: adb shell 命令的使用(am、pm、wm、screencap
  9. android的调试技巧,尤其是nativec等底层程序

随机推荐

  1. 自定义Android菜单背景
  2. Android(安卓)中各种XML文件的作用
  3. Android:开发中遇到的异常Error解析
  4. [Android] 来电归属地查询的实现思路
  5. A first hand look at building an Andro
  6. TableLayout
  7. android sim卡 TelephonyManager类:Androi
  8. Android(安卓)开发 — 开机自启动
  9. 2010.10.30———Android(安卓)03
  10. Android官方入门文档[14]停止和重新启动