Tushar Kathuria Tushar Kathuria - 6 months ago 34
Android Question

Unable to create emulator with Android version 4.0.3

I need to test my android app with android version 4.0.3 but I am unable to create an emulator with this Android version. Please check following screenshots for more details:

Installed Intel x86 system image for version 4.0.3:
Installed Intel x86 system image for version 4.0.3

No option for 4.0.3 version while selecting system image:
No option for 4.0.3 version while selecting system image

Already tried following with no luck:


  1. Restarted Android Studio

  2. Moved x86 folder from system-images/android-15/default to system-images/android-15 folder



How can I resolve this?

Edit:

As suggested by BrentM, I tried to create it using android command line tool. It was successfully created, but when I tried to edit it from Android Studio, then it gives an error: The specified image file must be a valid image file.

Address of the image file in system: /Android/Sdk/system-images/android-15/x86

Screenshot:
enter image description here

Answer

You are almost there. After creating the AVD via the command line, find the location of your AVDs. On my Mac they are in the .android/avd folder in my home directory. For reference the name of my new AVD is Api-15-Gnex. I edited two files (I am guessing there is a bug of some sort otherwise this should all be done through GUI). I edited the following two files (change as you see fit for your situation). Below are the how they look like at the end:

1) Api_15_Gnex.ini

avd.ini.encoding=UTF-8
path=/Users/kaamel/.android/avd/Api-15-Gnex.avd
path.rel=avd/Api-15-Gnex.avd
target=android-15

2) Api-15-Gnex.avd/config.ini

avd.ini.encoding=UTF-8
AvdId=Api_15_Gnex
abi.type=x86
avd.ini.displayname=Api 15 Gnex
disk.dataPartition.size=4G
hw.accelerometer=yes
hw.audioInput=yes
hw.battery=yes
hw.camera.back=none
hw.camera.front=none
hw.cpu.arch=x86
hw.dPad=no
hw.device.hash2=MD5:6930e145748b87e87d3f40cabd140a41
hw.device.manufacturer=Google
hw.device.name=Nexus 4
hw.gps=yes
hw.gpu.enabled=no
hw.gpu.mode=off
hw.keyboard=yes
hw.lcd.density=320
hw.mainKeys=no
hw.ramSize=512
hw.sdCard=yes
hw.sensors.orientation=yes
hw.sensors.proximity=yes
hw.trackBall=no
image.sysdir.1=system-images/android-15/default/x86/
runtime.network.latency=none
runtime.network.speed=full
runtime.scalefactor=0.1
sdcard.path=/Users/kaamel/.android/avd/Api-15-Gnex.avd/sdcard.img
skin.name=768x1280
skin.path=768x1280
skin.path.backup=/Applications/Android Studio.app/Contents/plugins/android/lib/device-art-resources/nexus_4
tag.display=Default
tag.id=default
vm.heapSize=48

After the edit there were no error and I could edit and/or run it like other AVDs. Just notice that the paths are specific to my setup and you need to change them to yours (like my home directory is at Users/kaamel, or my Android Studio is installed at /Applications/Android Studio.app, etc).

Good luck!

Additional information:

Make sure to check the Api_15_Gnex.ini (or whatever you named your AVD) as well. The last line, "target=android-15", must match the image.file.sysdir.1 target. They both must be the same, in this case android-15. Once you do that, even if you get the error, click on Show Advanced Settings and correct other errors (like skin name, internal storage, etc.) and when there are no more errors click finish and let it regenerate the AVD.