android 命令行模式启动模拟器

android 命令行模式启动模拟器

一般启动模拟器需要两个步骤:
1.创建AVD(Android Virtual Device)
2.启动emulator


当然也可以直接用emulator直接加载userdata.img镜像启动,这个是为什么我也不明白,这是我在命令行下面只输入emulator报错时,出现的提示信息

?
emulator: ERROR: You did not provide the name of an Android Virtual Device
with the '-avd <name>' option. Read -help-avd for more information.
If you *really* want to *NOT* run an AVD, consider using '-data <file>'
to specify a data partition image file (I hope you know what you're doing).
<BR> #命令如下<BR>emulator -data ~/xxxx/userdata.img

至于为什么要用上面说的那种方法,我也不太清楚,下面讲一下一般方法:
1.创建AVD
输入android create avd出现错误,并出现提示信息:

?
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)

帮助信息还是很足的,下面这个命令挺重要的,就是查看target

?
android list target
#就是create avd时需要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)

如果需要sdcard的话还要先建立一个sdcard.img

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

这样就很容易写出create avd命令了:

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

不太清楚为什么每次都要加-f参数,我test目录下也没有建立别的avd,不加的话会建立不成功。

2.启动模拟器

?
android list avd
emulator @emulator 2011

上述命令就是启动模拟器。

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


android 2.2的源码中也有上面说的那些命令,在~/xxxx/out/host/Linux-x86/bin目录下面

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值