Can I tweak my android emulator to make it fast?

2019-01-16 02:37发布

问题:

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

回答1:

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.



回答2:

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.



回答3:

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/



回答4:

  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.


回答5:

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

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


回答6:

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 :)



回答7:

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.



回答8:

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.



回答9:

You need to install Intel HAXM

  • open you SDK and install

  • Create a new AVD

  • Now when run it you should get this

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

see how much faster do you get Video



回答10:

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)



回答11:

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.



回答12:

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.



回答13:

  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