2012-10-11 37 views
14

Tôi muốn tạo trình giả lập trong dòng lệnh với một số tùy chọn, như hw.mainKeys = false. Tôi cần nó là một tập lệnh shell để có thể chạy thử nghiệm tự động hóa, tuy nhiên here Tôi không thể tìm thấy một nơi để đặt các giá trị đó.cách tạo trình giả lập Android trong dòng lệnh bằng các tùy chọn?

android create avd 

không có chỗ để chỉ định các tùy chọn đó.

Một thay thế là tạo ra một 'nền tảng' loại avd, tuy nhiên, lớp vỏ là một vỏ tương tác là rất tốt cho con người nhưng khó cho kịch bản

Android 4.1 is a basic Android platform. 
Do you wish to create a custom hardware profile [no]yes 

Name of the AVD being run: 
avd.name [<build>]: 

Có một số công cụ tôi chỉ có thể vượt qua tùy chọn như các thông số , như --hw.mainKeys false?

Trả lời

8

Bạn có thể tạo config.ini file văn bản với các thông số mong muốn

hw.lcd.density=252 
sdcard.size=32M 
skin.name=NEXUS-ONE 
skin.path=platforms/android-10/skins/NEXUS-ONE 
hw.cpu.arch=arm 
hw.keyboard.lid=no 
abi.type=armeabi 
hw.keyboard=no 
vm.heapSize=24 
hw.ramSize=256 
image.sysdir.1=platforms/android-10/images/ 

Xem tài liệu chính thức here

+1

làm thế nào tôi có thể sử dụng config.ini sau này? –

+1

đã nhận được. nó có thể được sao chép vào name.avd/folder. Cảm ơn –

+4

Kể từ tháng 8 năm 2016, "công cụ android" không còn được hỗ trợ, như nêu rõ ghi chú trên trang tài liệu https://developer.android.com/studio/tools/help/android.html. Điều này, một mặt, giải thích, tại sao tôi vẫn không thể làm cho nó hoạt động đúng trong Travis CI, nơi tôi sử dụng "android create avd" từ một dòng lệnh, và mặt khác, làm cho câu trả lời này lỗi thời - có vẻ như chúng ta cần tìm kiếm một số cách mới để tạo giả lập từ một dòng lệnh ... – yvolk

2

Hãy xem here

android create avd -n Ev o4G -t 9 -c 8000MB -s 480-800 
+1

Tôi không hỏi về tên, đích, da. nhưng các tùy chọn khác –

+0

Đây là lệnh android không được chấp nhận, fyi. – AnneTheAgile

0

chỉ cần sử dụng echo no | android create avd -n name -t 9

+0

không hoạt động với tôi (Ubuntu 14.04, công cụ 25.1.7) –

+2

Đối với câu trả lời của bạn, OP trước tiên nên chạy "mục tiêu danh sách android" và chọn mục tiêu có liên quan, anh ta có thể không có mục tiêu số 9. –

3

Từ android --help create avd:

Usage: 
    android [global options] create avd [action options] 
    Global options: 
    -s --silent  : Silent mode, shows errors only. 
    -v --verbose : Verbose mode, shows errors, warnings and all messages. 
    --clear-cache: Clear the SDK Manager repository manifest cache. 
    -h --help  : Help on a specific command. 

       Action "create avd": 
    Creates a new Android Virtual Device. 
    Options: 
    -t --target : Target ID of the new AVD. [required] 
    -a --snapshot: Place a snapshots file in the AVD, to enable persistence. 
    -c --sdcard : Path to a shared SD card image, or size of a new sdcard for 
      the new AVD. 
    -p --path : Directory where the new AVD will be created. 
    -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. 
    -n --name : Name of the new AVD. [required] 
    -s --skin : Skin for the new AVD. 
    -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. 
    -f --force : Forces creation (overwrites an existing AVD) 
1

Lệnh phi NỮA có ít tùy chọn dòng lệnh, nhưng đó là:

$ $ANDROID_HOME/tools/bin/avdmanager --help create 

Usage: 
     avdmanager [global options] create [action options] 
     Global options: 
    -s --silent  : Silent mode, shows errors only. 
    -v --verbose : Verbose mode, shows errors, warnings and all messages. 
    --clear-cache: Clear the SDK Manager repository manifest cache. 
    -h --help  : Help on a specific command. 

Valid actions are composed of a verb and an optional direct object: 
- create avd   : Creates a new Android Virtual Device. 

Action "create avd": 
    Creates a new Android Virtual Device. 
Options: 
    -a --snapshot: Place a snapshots file in the AVD, to enable persistence. 
    -c --sdcard : Path to a shared SD card image, or size of a new sdcard for 
       the new AVD. 
    -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. 
    -p --path : Directory where the new AVD will be created. 
    -k --package : Package path of the system image for this AVD (e.g. 
       'system-images;android-19;google_apis;x86'). [required] 
    -n --name : Name of the new AVD. [required] 
    -f --force : Forces creation (overwrites an existing AVD) 
    -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. 
Các vấn đề liên quan