Over the last couple of weeks, I have been testing my Android app on different devices. That work is going well. In this note, I’d like to share a couple of things that came out as side effects of that work, including:
- How to move Android virtual device (AVD) files from an Android Emulator to another machine.
- The set of AVD definitions that I found useful in checking an app on different screen sizes and screen densities.
How To Move AVD Files
There are a few things you need to understand about Android virtual device (AVD) files. The first is what they are. Basically, they are files that hold the description of an Android device and what’s on that device in the Emulator environment. If you need more information, start with the Android Developers note on “Managing Virtual Devices“.
Whether you are working alone or on a team, sooner or later you will want to know how to move your AVD files from one machine to another. Here’s what I have learned about that task.
Where do AVD definitions reside on your disk?
To find your avd folder on you machine, check your user directory. For me, with user name “blahti”, those locations are:
- Windows 7: \users\blahti\.android
- Windows XP: C:\Documents and Settings\blahti\.android\ on Windows XP
- Linux/Mac: ~/.android
Here’s a tip for new Mac users (like me). In the Finder window, you have to use the “Go To Folder” item on the “Go” menu to get to “~/.android”.
Steps for moving
Here are the basic steps:
- Go to the .android folder and pick the avd you want to export.
- Compress the device.avd folder and the device.ini file.
(Replace “device” with the name of the device you want to copy. For example: Evo4g.avd, Evo4g.ini.) - Copy the compressed files to the new location, usually on a different machine.
- Extract the files and place them in the user’s .android folder.
- Edit the ini file and make corrections, as needed:
(a) user name could be different; (b) change slash in path to Windows or Unix slash.
Example ini file contents on a Mac:
target=android-8 path=/Users/bill/.android/avd/Evo4G.avd
Example ini file contents on Windows 7:
target=android-8
path=C:\Users\blahti\.android\avd\Evo4G.avd
Example ini file contents on Windows XP:
target=android-8 path=C:\Documents and Settings\blahti\.android\avd\Evo4G.avd
Start the AVD Manager under Eclipse and be sure the files are readable. See Figure 1 below.
Figure 1 – Start the AVD Manager in Eclipse
If there is an error, a red X is displayed, as in Figure 2. Highlight the item, and see if the “Repair” button is enabled. Click “Repair” if it is. Or click the “Details” button for more information. In most cases, it will be something wrong with the path in the ini file you just edited. .Always check that first. After you edit a file, click the “Refresh” button to see if your correction worked. Figure 3 shows that all corrections have been accepted.
Figure 2 – AVD Manager shows errors
Figure 3 – AVD Manager shows corrections
To use the new AVD definitions, run the ADB Device Manager. You will need two pieces of information: (a) the diagonal measure for your computer’s screen; (b) the actual size of the screen for the Android phone or device.
Click “Start…” and fill in the diagonal screen size.
Figure 4 – Start a Device from the AVD Manager
Here are a few values for diagonal size (the “d” value). If you are testing with other devices, a Google search for your phone name with the word “specs” usually gets you what you want.
HTC Evo 480 x 800, LCD 217, d 4.3
Motorola Droid 3 – 540 x 960, LCD 275, d 4
Motorola Droid – 480 x 854, LCD 265, d 3.7
NexusOne – 480 x 800, LCD 252, d 3.7
LG Optimus S – 320 x 480, LCD 180, d 3.2
HTC Tattoo, 240 x 320, LCD 143, 2.8 — small screen, low density
My Set of Android Virtual Devices For Testing
Here is the set of virtual device definitions that I have been using in my testing. The set includes large and small screen sizes and low, medium, and high density screens. I have not tried tablets yet.
To get the zip files for these AVD definitions, go to my shared avd folder in Google Docs. When you get there, do not click on the zip files there. Instead right-click with the mouse button (control-click on a Mac). That gets you to a menu with a “Download” link on it.
To use them, just download the zip file and move the files to the right place, as described in the first section of this note. Each of these comes with a Dashboard UI Demo app already installed. To give you an idea of what these different devices look like, here’s a screenshot of the six devices running a demo program. Basically, it looks reasonable except on the small screen of the HTC Tattoo.
Figure 5 – Demo program running on different virtual devices
The AVD files encode the device information shown in the previous section. If you add more device definitions and have to calculate the LCD value, here is the formula:
LCD = sqrt (x^2 + y^2) / d
References
I’d like to thank once again the Android community, and particularly the people who support the Android Developers website, for their willingness to share information and help one another. Here are the references I found most useful for this work:
Managing Virtual Devices – an intro article on the Android Developers website. It describes what an AVD file is, what it contains, and how it’s used in the Android Emulator.
Supporting Multiple Screens – a good place to start to understand how to deal with the different screen sizes and densities. Once you start testing on multiple devices, you’re likely to discover that you have problems. This article and the next one are essential references.
Providing Resources – an article on how you structure your application to handle different devices.
Question at StackOverflow about testing on multiple devices – I liked the suggestions about which set of devices to choose for a representative set, given the current statistics on actual devices in use.
Screen Sizes and Densities – current data on what devices are in use. This was mentioned in the Stack Overflow note above.
Hi,
Great tutorial, but unfortunately I am unable to download your AVD samples =(
How did the download fail? I have found that there are some countries (e.g. China) where people cannot access anything stored at a Google site, which is where the downloads are. I put them in a public Google Docs folder.
What country are you in?
Most fail for me as well.
Google docs starts up and complains that it can’t display the document.
That happens for all of them I’ve tried except the Evo 4G.
Do you click on the zip file and see a message like “Sorry, we are unable to generate a view of the document at this time.” ? I see that message too — not all the time, but sometimes. I think that means that the latest change in Google Docs is to do a preview of the zip file.
I have found a way around the problem, but I have to provide another link. Here is the link to the avd folder that holds all the zip files. When you get there, do not click on the file name. Instead do a right-click on the file name. That should get you to a menu with “Download” on it. Let me know if that works.
Yes, that is what I see. I was able to get the first one, then nothing.
I have updated the blog article. I include the link to an AVD folder where the zip files are stored. I hope that will make it easier for people to download them. I’ll also be looking around for a new place to store files.
I’ve been using Dropbox recently for that kind of thing.
It worked perfectly now. Thank you!
Pingback: Move Android AVD | Y12 Studio
Nice article.
In my case, instead of downloading images from Google on each machine, I simply copied content of C:\Program Files (x86)\Android\android-sdk\platforms (Windows path) as well. With them, to get a new PC up and running with the Emulator, you simply need to install the Emulator software itself and you don’t need to download anything else.
I will have to try that. Thanks.
thanks for this information and sharing files 🙂
I have downloaded htctatto.zip and changed .ini files and also created a folder with name android-8 in android-sdk]platforms\, but when I does android list in cmd is says emulator: ERROR: This AVD’s configuration is missing a kernel file
i am new in this pls pls help me
i have downloaded SDK installer_r20.0.3-windows and java1.6 and have set path in env variable but not installed ecllips…..
I hope that will work without it
thanks
When I prepared these files, I was using Android API level 8. To load them, you need to have API 8 installed. Use the Android SDK Manager window to do that. It’s on the Eclipse Window menu, near the bottom. It looks like this:
very nice tutorial you can also check this one
http://www.pavanhd.blogspot.in/2013/05/how-to-create-android-virtual-device.html
Hi,
very nice tutorial. Do you know is it legal to share android virtual machines online?
I do not know. I would assume it is as long as you follow the licensing requirements of whoever provided the virtual machines initially. However, I am not a lawyer. Perhaps you should consult one.
nice tutorial thank u sir for sharing such a useful information………..Thanks
Hi There Thanks for the one and only tutorial that is available to move Android virtual devices. I am running android studio 2.0 on ubuntu. but your steps did not work for me. even after renaming the paths in the ini files. it still says image missing and prompts to download. can you help me out in this.
Unfortunately, I have not done much work in Android Studio yet. So I don’t have any suggestions. Sorry.
Thanks, I downloaded NexusOne, change the target to Android4.1.2 in NexusOne.ini
Then the abi.type in NexusOne.avd/config.ini to abi.type=armeabi-v7a
and updated .. with
android -v update avd -n NexusOne
it works under ubuntu xerial and eclipse Neon Release (4.6.0)
Good to hear that the transfer technique still works.