如何使用命令行和avdmanager创建Android虚拟设备?

时间:2017-03-14 17:39:48

标签: android

我无法使用avdmanager命令行创建设备:

from __future__ import division, print_function
from visual import *
scene.width = 400
scene.height = 760
## constants and data
g = 9.8
mball = 0.03
L0 = 0.26
ks = 1.8
sf = .5
sf2 = 3

#Graphs


## objects (origin is at ceiling)
ceiling = box(pos=vector(0,0,0), length=0.2, height=0.01, width=0.2)
ball = sphere(pos=vector(0,-0.3,0), radius=0.025, color=color.orange)
spring = helix(pos=ceiling.pos, axis=ball.pos-ceiling.pos,color=color.cyan, thickness=.003, coils=40, radius=0.010)
#more constants
Lvec= (ball.pos-ceiling.pos)
Lhat = Lvec / mag(Lvec)
## initial values
pball = mball*vector(0,0,0)
Fgrav = mball*g*vector(0,-1,0)
t = 0
deltat = .01
Fspring = -ks*ball.pos

#arrow vectors
Fharr = arrow(pos=ball.pos, axis=vector(0,0,0), color=color.green) #parallel
Ftarr = arrow(pos=ball.pos, axis=vector(0,0,0), color=color.blue) #perpendicular
parr = arrow(pos=ball.pos, axis=vector(0,0,0), color=color.magenta)

#improve the display
scene.autoscale = False ## turn off automatic camera zoom
scene.center = vector(0,-L0,0) ## move camera down
#scene.waitfor ('click')

## calculation loop
while t <10:
    rate(100)
    #length of L
    Lmag=abs(Lvec.y)
    Lhat = Lvec / mag(Lvec)
    #spring force
    Fspring = -ks*(mag(Lvec)-L0)*Lhat
    #updating position
    Fnet = Fgrav + Fspring
    pball = pball + Fnet*deltat
    ball.pos = ball.pos + (pball/mball)*deltat
    spring.axis = ball.pos - ceiling.pos
    #perpendicuar and parrellel forces
    phat = pball/mag(pball)
    #parallel
    FH = dot(Fnet,phat)*phat
    #perpendicular
    FT = Fnet - FH
    #updating arrows

    t = t + deltat

有什么想法吗?

3 个答案:

答案 0 :(得分:33)

如果您不关心它是Nexus 6P,您可以运行 echo no | Android/Sdk/tools/bin/avdmanager create avd --force --name testAVD --abi google_apis/x86_64 --package 'system-images;android-23;google_apis;x86_64'

答案 1 :(得分:9)

这是我在Mac上运行的命令 注意:

  1. x86和x86_64是不同的ABI。
  2. 您需要先从sdkmanager
  3. 下载system_image
    $  avdmanager create avd --force --name testAVD --abi google_apis/x86 --package 'system-images;android-23;google_apis;x86'
    
    Do you wish to create a custom hardware profile? [no] no
    
    $  avdmanager list avd
    
    
    Name: testAVD
    Path: /Users/xj/.android/avd/testAVD.avd
    Target: Google APIs (Google Inc.)
          Based on: Android 6.0 (Marshmallow) Tag/ABI: google_apis/x86
    

答案 2 :(得分:8)

来自@ Gregriggins36的解决方案有效。这里是我在Linux上使用的详细解决方案(Fedora 27)

列出可用的设备定义:

~/Android/Sdk/tools/bin/avdmanager list
...
---------
id: 11 or "Nexus 6P"
    Name: Nexus 6P
    OEM : Google
---------
...

根据设备定义"Nexus 6P"

创建虚拟设备

~/Android/Sdk/tools/bin/avdmanager create avd --force --name Nexus6P --abi google_apis/x86_64 --package 'system-images;android-23;google_apis;x86_64' --device "Nexus 6P"

列出可用的虚拟设备

~/Android/Sdk/tools/bin/avdmanager list avd
Name: Nexus6P
Device: Nexus 6P (Google)
Path: /home/guillaume/.android/avd/Nexus6P.avd
Target: Google APIs (Google Inc.)
        Based on: Android 6.0 (Marshmallow) Tag/ABI: google_apis/x86_64

开始模拟我们的新虚拟设备

~/Android/Sdk/tools/emulator -avd Nexus6P -skin 1440x2560