-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_avd.py
More file actions
51 lines (43 loc) · 1.53 KB
/
create_avd.py
File metadata and controls
51 lines (43 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
import sys, os, argparse, subprocess, platform, time
def main():
parser = argparse.ArgumentParser()
parser.add_argument('number', help='number of AVDs you want to create',
type=int)
parser.add_argument('path', help='path to your Android SDK')
parser.add_argument('-a', '--arch', help='the architecture (x86 or arm)',
default='x86')
parser.add_argument('-d', '--device', help='Device name or ID',
default='2.7in QVGA slider')
parser.add_argument('-v', '--api', help='Android API version',
type=int, default=19)
args = parser.parse_args()
arch = abi = args.arch
api = args.api
device = args.device
path = args.path
if arch == "arm":
abi = "armeabi-v7a"
elif arch != "x86":
print "Supported architectures are x86 (default) or arm"
return
android_version = 'android-' + str(api)
image_path = 'system-images;' + android_version + ';google_apis;' + abi
print 'sdkmanager "' + image_path + '"'
subprocess.call(["sdkmanager", image_path], shell=True)
for i in range(args.number):
n = str(i)
cmd = [ 'avdmanager', 'create', 'avd', '-n', 'avd' + n, '-b', abi, '-f',
'-c', '64M', '-k', image_path, '-d', device ]
print
print ' '.join(cmd)
if platform.system() == "Windows":
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, shell=True)
else:
p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
p.communicate(input='no\n')
print
print "Waiting for avdmanager to exit"
p.wait()
if __name__ == "__main__":
main()