2

I am trying to create an Android Virtual Device from command line. My code is following:

def create_emulator():
    emulator_name = "samsung_2"
    target_id = '5'
    abi = "android-tv/x86"
    android = config.config_file_reader('android')
    tools = config.config_file_reader('tools')

    emulator_create = str(subprocess.check_output([android,'create', 'avd', '-n', emulator_name, '-t', target_id, '-b', abi],stdin=subprocess.PIPE))
    emulator_create.stdin.write('no')
    return emulator_create

But it shows me the following error

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.checkBounds(String.java:381)
    at java.lang.String.<init>(String.java:545)
    at com.android.sdkmanager.Main.readLine(Main.java:1786)
    at com.android.sdkmanager.Main.promptForHardware(Main.java:1661)
    at com.android.sdkmanager.Main.createAvd(Main.java:1448)
    at com.android.sdkmanager.Main.doAction(Main.java:337)
    at com.android.sdkmanager.Main.run(Main.java:151)
    at com.android.sdkmanager.Main.main(Main.java:117)
Traceback (most recent call last):
  File "/home/fahim/PycharmProjects/test_1/main_runner.py", line 27, in <module>
    main()
  File "/home/fahim/PycharmProjects/test_1/main_runner.py", line 9, in main
    instances = emulator.create_emulator()
  File "/home/fahim/PycharmProjects/test_1/emulator_manager.py", line 21, in create_emulator
    emulator_create = str(subprocess.check_output([android,'create', 'avd', '-n', emulator_name, '-t', target_id, '-b', abi],stdin=subprocess.PIPE))
  File "/usr/lib/python2.7/subprocess.py", line 574, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['/home/fahim/Android/Sdk/tools/android', 'create', 'avd', '-n', 'samsung_2', '-t', '5', '-b', 'android-tv/x86']' returned non-zero exit status 1

Process finished with exit code 

1 what can i do?

Mutasim Fuad
  • 606
  • 2
  • 12
  • 31
  • Kind of possible duplicate: [What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?](http://stackoverflow.com/questions/5554734/what-causes-a-java-lang-arrayindexoutofboundsexception-and-how-do-i-prevent-it). An ArrayIndexOutOfBoundsException is not exactly the same as a StringIndexOutOfBoundsException, but their causes are similar, so I think you can fnd some guidance there. – Ole V.V. Nov 07 '16 at 10:33

0 Answers0