手动建立模拟器
./mksdcard 512M sd01
512M是SD卡大小,sd01是指卡的名称
./android create avd -n phone01 -t 2
参数 -n name -t targetId
运行后出现
Auto-selecting single ABI armeabi-v7a
Created AVD 'myphone01' based on Google APIs (Google Inc.), ARM (armeabi-v7a) processor,
with the following hardware config:
hw.lcd.density=240
vm.heapSize=48
hw.ramSize=512
运行模拟器
sudo ./emulator @phone01 -sdcard sd01 -scale 0.8
模拟器上网设置:
android 模拟器默认情况下是无法上网的,因为其默认的DNS是10.0.2.3,可将其设为本机IP
Ubuntu 下可用 ifconfig查看IP
adb shell进入模拟器shell
getprop 查看系统各项属性
其中[net.dns1]: [10.0.2.3]
setprop net.dns1 192.168........
adb指定设备安装apk:
sahwn@EP43:~/IdeaProjects/untitled$ adb --help
Android Debug Bridge version 1.0.31
-s <specific device> - directs command to the device or emulator with the given
serial number or qualifier. Overrides ANDROID_SERIAL
environment variable.
devices [-l] - list all connected devices
('-l' will also list device qualifiers)
device commands:
adb install [-l] [-r] [-s] [--algo <algorithm name> --key <hex-encoded key> --iv <hex-encoded iv>] <file>
- push this package file to the device and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data)
('-s' means install on SD card instead of internal storage)
('--algo', '--key', and '--iv' mean the file is encrypted already)
sahwn@EP43:~/IdeaProjects/untitled$ adb -s HC34XW903192 install -r untitled.apk3857 KB/s (979989 bytes in 0.248s)
pkg: /data/local/tmp/untitled.apk
Success