1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > android 开机进入命令行模式 android 命令行模式启动模拟器

android 开机进入命令行模式 android 命令行模式启动模拟器

时间:2020-01-04 03:02:33

相关推荐

android 开机进入命令行模式 android 命令行模式启动模拟器

启动模拟器需要两个步骤:

1.创建AVD(Android Virtual Device)

2.启动emulator

一般使用Eclipse开发时,开启一个模拟器就是这么一个过程,其实命令行模式下也是这样。刚开始不知道如何命令行启动模拟器的时候就输入了一个emulator,报错了,出现如下提示:

emulator: ERROR: You did not provide the name of an Android Virtual Device

with the '-avd ' option. Read -help-avd for more information.

If you *really* want to *NOT* run an AVD, consider using '-data '

to specify a data partition image file (I hope you know what you're doing).

1.创建AVD

根据提示信息说明,需要先有一个AVD,即一个android的虚拟设备,在命令行输入android create avd,当然前提是在linux中配置好了环境变量,否则会出现找不到命令的错误提示的。如果环境变量配置正确会出现了错误提示信息:

Error: The parameters --name, --target must be defined for action 'create avd'

Usage:

android [global options] create avd [action options]

Global options:

-s --silent Silent mode: only errors are printed out.

-h --help Help on a specific command.

-v --verbose Verbose mode: errors, warnings and informational messages are printed.

Action "create avd":

Creates a new Android Virtual Device.

Options:

-c --sdcard Path to a shared SD card image, or size of a new sdcard for the new AVD

-s --skin Skin for the new AVD

-a --snapshot Place a snapshots file in the AVD, to enable persistence.

-n --name Name of the new AVD [required]

-p --path Directory where the new AVD will be created

-t --target Target ID of the new AVD [required]

-f --force Forces creation (overwrites an existing AVD)

根据上述所提到的参数,并通过查资料得到了-t --target参数如何获得。在命令行下输入android list target,显示如下:

android list target

Available Android targets:

id: 1 or "android-8"

Name: Android 2.2

Type: Platform

API level: 8

Revision: 2

Skins: WQVGA432, WQVGA400, HVGA, WVGA854, QVGA, WVGA800 (default)

其中的id:这一行就是我们需要的target的参数

如果启动的模拟器还需要sdcard的话,还需要首先创建一个sdcard的镜像

mksdcard -l sdcard 512M ~/xx/sdcard.img

这样就很容易写出创建AVD的命令了

android create avd -c ~/xxx/sdcard.img -n emulator -p ~/test/ -t 1 -f

2.启动模拟器

首先通过android list avd 查看建好的虚拟设备

Available Android Virtual Devices:

Name: android.2.2

Path: /home/XXX/.android/avd/android.2.2.avd

Target: Android 2.2 (API level 8)

Skin: HVGA

---------

Name: emulator

Path: /home/XXX/test

Target: Android 2.2 (API level 8)

Skin: WVGA800

Sdcard: /home/XXX/sdcard.img

然后通过命令

emulator @emulator

就启动了第二个类型的模拟器。

其实用命令行启动模拟器和eclipse里启动是相同的。上面两个步骤就是对应eclipse中创建avd和启动模拟器的过程,使用eclipse创建avd,它会在家目录下建立.android的隐藏文件夹,将avd的信息全都放到这里面。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。