Android-ADB命令常用方法

   Android 命令提供了SDK版本的查看、更新,虛擬機的創建、修改、刪除以及Android項目的創建編譯以及打包,是Android開發中重要的命令。

        我們要使用ADB,第一件事情就是學會使用Android的常用命令。

1、查看目前可用的Android平臺:
    android list targets

C:\Windows\System32>android list targets
Available Android targets:
----------
id: 1 or "android-10"
Name: Android 2.3.3
Type: Platform
API level: 10
Revision: 2
Skins: WVGA800 (default), WVGA854, WQVGA400, WQVGA432, HVGA, QVGA
Tag/ABIs : default/armeabi, default/x86
----------
id: 2 or "Google Inc.:Google APIs:10"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 2
Description: Android + Google APIs
Based on Android 2.3.3 (API level 10)
Libraries:
* com.android.future.usb.accessory (usb.jar)
API for USB Accessories
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: WVGA854, WVGA800 (default), WQVGA432, HVGA, QVGA, WQVGA400
Tag/ABIs : default/armeabi

2、顯示系統中的全部AVD(Android Virtual Drvice)
    android list avd
C:\Windows\System32>android list avd
Available Android Virtual Devices:
Name: Intel
Device: 3.2in QVGA (ADP2) (Generic)
Path: C:\Users\小敏\.android\avd\Intel.avd
Target: Android 2.3.3 (API level 10)
Tag/ABI: default/x86
Skin: 320x480
Sdcard: 512M
---------
Name: Test
Path: C:\Users\小敏\.android\avd\Test.avd
Target: Android 2.3.3 (API level 10)
Tag/ABI: default/x86
Skin: WVGA800

3、創建AVD

Creates a new Android Virtual Device.
Options:
-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.
-c --sdcard : 新的SD卡的大小或者老的SD卡的路徑. 
-n --name : AVD的名稱. [required]
-a --snapshot: 快照文件路徑.
-p --path : 虛擬機的存放路徑.
-f --force : 強制創建(覆蓋已存在的AVD)
-s --skin : AVD的皮膚.
-t --target : 虛擬機的Android操作系統ID,也就是上面那個命令的“id: 1 or "android-10"”. [required] 
-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.

    例如:android create avd --name ${avd名稱} --target ${平臺編號} --abi ${cpu平臺}
    eg: android create avd --name Test --target 1 --abi x86

C:\Windows\System32>android create avd --name Test --target 1 --abi x86 -f
Android 2.3.3 is a basic Android platform.
Do you wish to create a custom hardware profile [no]
Created AVD 'Test' 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
C:\Windows\System32>android list avd
Available Android Virtual Devices:
Name: Intel
Device: 3.2in QVGA (ADP2) (Generic)
Path: C:\Users\小敏\.android\avd\Intel.avd
Target: Android 2.3.3 (API level 10)
Tag/ABI: default/x86
Skin: 320x480
Sdcard: 512M
---------
Name: Test
Path: C:\Users\小敏\.android\avd\Test.avd
Target: Android 2.3.3 (API level 10)
Tag/ABI: default/x86
Skin: WVGA800

4、刪除AVD
    android delete avd -n Test 
C:\Windows\System32>android delete avd -n Test
Deleting file C:\Users\小敏\.android\avd\Test.ini
Deleting folder C:\Users\小敏\.android\avd\Test.avd
AVD 'Test' deleted.

5、啓動AVD
    emulator -avd Test

6、其他命令請使用android -h進行查閱:
C:\Windows\System32>android -h
Usage:
android [global options] action [action options]
Global options:
-h --help : Help on a specific command.
-v --verbose : Verbose mode, shows errors, warnings and all messages.
--clear-cache: Clear the SDK Manager repository manifest cache.
-s --silent : Silent mode, shows errors only.
Valid
actions
are
composed
of a verb
and an
optional
direct
object:
- sdk : Displays the SDK Manager window.
- avd : Displays the AVD Manager window.
- list : Lists existing targets or virtual devices.
- list avd : Lists existing Android Virtual Devices.
- list target : Lists existing targets.
- list device : Lists existing devices.
- list sdk : Lists remote SDK repository.
- create avd : Creates a new Android Virtual Device.
- move avd : Moves or renames an Android Virtual Device.
- delete avd : Deletes an Android Virtual Device.
- update avd : Updates an Android Virtual Device to match the folders
of a new SDK.
- create project : Creates a new Android project.
- update project : Updates an Android project (must already have an
AndroidManifest.xml).
- create test-project : Creates a new Android project for a test package.
- update test-project : Updates the Android project for a test package (must
already have an AndroidManifest.xml).
- create lib-project : Creates a new Android library project.
- update lib-project : Updates an Android library project (must already have
an AndroidManifest.xml).
- create uitest-project: Creates a new UI test project.
- update adb : Updates adb to support the USB devices declared in the
SDK add-ons.
- update sdk : Updates the SDK by suggesting new platforms to install
if available.
發佈了6 篇原創文章 · 獲贊 5 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章