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).
#命令如下
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目录下面
浙公网安备 33010602011771号