60

I am using the android emulator to run my programs. But its really slow. It takes around 90 seconds to startup and show the home screen. Can I tweak it so that I can reduce this time considerably? Thanks

Bohemian
  • 5,957
  • 11
  • 38
  • 47

13 Answers13

35

I was having a similar problem (thread here). However, mine was taking 10-15 mins. 90 seconds is blazing fast considering a lot of threads in the Android discussion groups. The emulator is slow by nature and the only recommendation I read was to keep the emulator open instead of closing it and rerunning it. However, as mentioned in my thread, if you have a physical Android device, you can just run it on that. It's what I'm doing at the moment and it was top-notch advice. No long waiting time. If you don't have a physical device, then I can only suggest you don't close the emulator between code changes, as the system will recognise the change.

Community
  • 1
  • 1
keyboardP
  • 68,824
  • 13
  • 156
  • 205
  • 3
    Yeah exactly. Let the emulator run n rerun the code after editing. Its like hot swappable. Thanks – Bohemian Dec 28 '09 at 06:18
  • 1
    I didn't look at the link, but for my system I'm looking at times that are more like: first boot: 90sec, subsequent boot: 15-20sec boot. I'm not on blazing-fast hardware (laptop, 2ghz core2-duo, 4gig ram), Ubuntu... is it possible something else is slowing it down? – Jeremy Logan Dec 28 '09 at 06:40
  • 1
    Leaving it running is very useful indeed. I personally switched to using the phone itself as the only debug tool. Just connect the cable, configure it and it runs immediately, no need to wait, plus supports orientation changes... Regards, Ari – BeMeCollective Dec 28 '09 at 10:03
  • 1
    @fiXedd: I'm not sure if there are that many ways to speed it up. Before I actually used a physical device, I was looking around for various ways to increase the speed of the emulator, but I couldn't really find much information on it. Even if there are a few minor changes you can make, I don't know how significant the speed up will be on current versions of the emulator. – keyboardP Dec 28 '09 at 15:08
  • You can't run different versions of the app on one device. How are you going to test 1.5 on a 2.1 device? – gcb Oct 23 '10 at 10:40
  • @gcb - I haven't done any Android programming lately, so I don't know if the emulators have been made faster lately. Still, if you have to test your program on a device you don't have, you don't really have any choice but to use the emulator. A good idea could be to get your program running to a decent level on your current phone, then use the emulator for the other versions. – keyboardP Oct 23 '10 at 21:10
31

use those 3 options.

emulator --cpu-delay 0 --no-boot-anim --cache ./cache --avd avd_name

the first two are obvious. the third one will make the memory of the emulator kind of persistent. you can point it to any file that does not get destroyed by boot (such happens with /tmp) it's like a always-on hibernating device.

gcb
  • 13,901
  • 7
  • 67
  • 92
  • Where do we save this? At what file location? – Thompson Feb 28 '15 at 19:17
  • @Thompson if you mean where the cache file will be, well anywhere. `./` means "at the place where i'm at when i run this command". but you can replace it with any file (which will be created if do not exist) such as `--cache /home/thompson/androidcache` – gcb Mar 01 '15 at 20:53
9

If you absolutely cannot use a physical Android device, what you can do is run the Android OS on Virtualbox, and then get the IP address of the emulated Android. Then you'd connect ADB to the emulator using that IP address. That's the jist of it. I've written a more detailed guide to this approach on my blog. http://www.bobbychanblog.com/2011/07/faster-android-emulator-alternative-using-virtualbox/

Bobby
  • 744
  • 9
  • 12
7
  1. The -no-boot-anim parameter is good.
  2. Don't turn the emulator off, just re-launch your app.
  3. For further speedups, try the new snapshot feature, which is described here.
Tomas Andrle
  • 13,132
  • 15
  • 75
  • 92
2

I recommend you to use Genymotion . It's a very fast emulator (less than 10 seconds to run in my case)

It has Google Apps installed also including Google Play App which give the chance to download any app. This is a good feature for testing apps with Maps Api.

Community
  • 1
  • 1
Mongi Zaidi
  • 1,043
  • 10
  • 15
2

You need to install Intel HAXM

  • open you SDK and install

enter image description here

  • Create a new AVD

enter image description here

  • Now when run it you should get this

enter image description here

if not then you will need to install Accelerated Execution Manager

See this Running the new Intel emulator for Android on how can you do this

enter image description here

see how much faster do you get Video

Community
  • 1
  • 1
Mina Gabriel
  • 23,150
  • 26
  • 96
  • 124
  • I followed the steps you have mentioned and i am able to start my emulator using intel x86_64 virtual device in 60 seconds..but i dont see any "HAX is working and emulator runs fast in virt mode"..i have windows 7 64 bit..Intel HAXM 1.1.1 is installed..Virtualization is also supported in my PC.. – Lucky Dec 16 '14 at 12:12
2

Scaling the emulator down made my emulator load faster...

emulator -cpu-delay 0 -no-boot-anim -cache ./cache -scale 0.8 -avd avd_name
RichardTheKiwi
  • 105,798
  • 26
  • 196
  • 262
sulabh
  • 1,097
  • 1
  • 8
  • 22
  • i actually got worse results with -scale. Nothing noticeable without measurement, but it was worse. – gcb Jun 08 '11 at 22:01
2

actually these are all great answers, but have u thought of changing the ram from the default 96mb to something like 512? works for me :)

jay
  • 21
  • 1
2

If you have the mobile device with you, it's much quicker (and more reliable) to compile it via USB to the device. It takes around 5 seconds to compile and install on your phone, I never use the emulator anymore - it's just to slow.

Not only is it slow but anything other than static widgets (animation) will struggle to run on the emulator and you will notice lag.

Ricky
  • 7,785
  • 2
  • 34
  • 46
  • 1
    Real device really is the only way to go. It is just streets faster. – Robert Massaioli Jun 28 '11 at 02:45
  • It's not feasible to have one device to each combination of screen size and OS version. Even if it was, people would be asking how to keep 12 phones on the table :) ...the main issue with the emulator is that it only uses one CPU even on a 8core i7. But it's still the only way to automate nightly tests in several devices (and since it only uses one CPU, you can run 8 jobs :) – gcb Aug 28 '13 at 04:25
1

While developing my game, Elastic World, I was suffering from the same problem. After waiting minutes for the emulator to startup, the game was running at 20 FPS maximum. Even on low end android devices I could easily get 60 FPS.

So I moved to a VMWare Android machine, following the instructions from this site: http://www.android-x86.org/documents/installhowto/

The same game loop now runs at 250 FPS. (it's not playable at this speed and I have the game limited to max 60 FPS, but overriding this limitation it gives 250 FPS)

Pedro Soares
  • 1,117
  • 12
  • 14
0

Just enable "Snapshot" checkbox in your AVD Manager. It will save the state of your AVD when you close it. So, once you run the emulator again, that saved state will be loaded. Hence the boot up time of your AVD will be considerably reduced.

0
  1. First I follow this introduction
  2. Run emulation with command : emulator -cpu-delay 0 -no-boot-anim -cache ./cache -avd <adv-name> -gpu on (follow link and link)

results is run ~2-3x faster

Community
  • 1
  • 1
nguyên
  • 5,156
  • 5
  • 43
  • 45
0

Try to use a smaller resolution for your emulator as for example HVGA. The emulator gets slower the more pixels its needs to render as it is using software rendering.

Also if you have sufficient memory on your computer, add at least 1 GB of memory to your emulator. This is the value "Device ram size" during the creation of the AVD.

Also set the flag "Enabled" for Snapshots. This will save the state of the emulator and let it start much faster.

bilalhaider
  • 181
  • 2
  • 5
  • 15