Skip to content

Getting the Android Emulator to Work on the Macbook Pro Retina Display

by Kevin Hoffman on August 6th, 2012

Recently I posted about my thoughts on the first impression left by the Android SDK using Eclipse and the ADT Plugin for Eclipse (this is the “traditional route” of Android developers). My first impression was less than stellar.

So I wondered if the inherent crappiness in this was due to Windows or just that overall patchwork, cobbled together Rube Goldberg feeling you get when working with certain open source projects above a certain size. So, I pulled out the Macbook Pro (a 2012 retina display model, the retina display will play a key factor in my impression) and went through the process of installing the SDK.

The Android SDK installs just fine on OS X Mountain Lion and Eclipse “Juno” installed just fine as well. I had trouble with the SSL URL for the developer tools that many books and Google themselves give you, and even had trouble just removing the S from HTTP in the URL, having to decipher what the plugin URL was for the non-SSL download. Really, they could make that process a crapload easier. Again, I had this problem both on Windows and Mac, so the suck was cross-platform.

After finally getting all of the various pieces of the puzzle installed on the Mac, I went through the process of creating an Android Virtual Device (AVD). I started the emulator and noticed that it showed up in a big window but was only drawing on a small portion of it. It didn’t seem to respond to mouse-clicks.

I wasted hours of my life “troubleshooting” this issue, checking everything from memory issues to bad APIs to re-installing the SDK. After a while of swearing and pounding the forehead against the desk, I noticed that it actually did respond to mouse-clicks, but in empty areas of the window. A button that was in the bottom of the drawn portion would respond in the bottom of the larger, empty window. A-HA!

I then thought:

I’ll bet the retina display’s annoying scaling crap is actually confusing the emulator.

Turns out I was right. The emulator is using a deprecatedabsurdly old piece of code that is unaware of situations when the pixels being drawn are not in the same place as the pixels being displayed. I could either wait for Google to fix this (really Google, this is inexcusable in a non-beta, shipping product. Open source or no, this is bull****) or I could settle for a temporary workaround.

That temporary workaround is a tool I found called SetResX. This tool allows you to set real resolution not the annoying “best for retina” and “not so best for retina” user-friendly options you get with the Mountain Lion and Lion settings dialogs. All you need to do is pick any resolution big enough to support a 1:1 pixel-faithful resolution of your emulated screen (e.g. I picked 1680×1050 to support my emulated tablet’s 1080p HD resolution) and you can then run the emulator without the bizarre side-effects.

So, what this highlights in my experience are two things, in order of suckiness:

  1. Shame on Google for releasing non-beta, shipping tools that use deprecated, out-of-date API calls that are incompatible with any Mac retina display.
  2. Shame on Apple for their Macbook Pro Retina display. They release it and without an external tool like SetResX, you can’t actually access all of the pixels the monitor is capable of, you just get scaled and obscured versions. This is a little disappointing, really. It’s my damn computer, don’t pretend to know what’s best for me and hide all of the possible resolutions the card/monitor is capable of from me. Apple used to typically allow developers to get around such “we know what’s best for you” assumptions with standard Unix command-line tools, but there is no such stock tool in this case.

So, if you have a Retina Display Macbook Pro and you want to do some Android development off-device, you’re going to need a tool that futzes with your resolution, or, you can actually hook your laptop up to a non-retina monitor and slide the emulator window onto that monitor and you no longer have an issue (because the non-retina monitor has a 1:1 pixel faithful copy).

In my quest for things that follow the kotan (elegant simplicity) philosophy, my experience with the Android toolset is that it eschews both elegance and simplicity.

From → Mobile, Technology

  • Dan

    Just curious but right click emulator app, Get Info, and checking Open in Low Resolution didn’t help?

    • kotancode

      The tricky part is I don’t launch the emulator app directly, it gets launched by Eclipse through the “AVD Manager”, which is actually launched as a result of invoking a command-line utility that uses Java AWT under the covers.

    • kotancode

      Just poked around. The application responsible for the emulator is a command-line tool called emulator-arm, which does not have the “Open in Low Resolution” mode because it’s a Unix executable file.

      • Dan

        Yeah, I’m noticing a lack of options there. Searching for any CLI options or where OS X keeps its list of apps to run low res. Maybe if Eclipse or some other layer under as long as there’s an “app” has it checked it’ll pass it thru. But it’d be a crime to have a retina display and not be able to use it to view source.

        • kotancode

          Yes, after having seen text on the retina display, I can’t go back to coding without it. The real problem is just that the folks who wrote the emulator shell are lazy about upgrading deprecated API calls. ALL they have to do is change a library binding from version X to version X+2 and the problem goes away.

          • Dan

            Tried seeing if I could trace down where the Open in Low Res is stored for apps through Instruments, but no go, to much data or I’m just not seeing it, hmm… haven’t had coffee yet. Apparently after using SetResX and starting the emulator you can flip back to a normal res and the emulator will keep working. Anyways, everything else I’m seeing is that google’s working on a fix.

  • marksoper

    Thanks for this post. I had the same problem and this helped me to figure it out!

  • LK

    Big thanks for this post

  • http://twitter.com/lakhanir Rehan Lakhani

    I have found somewhat of a fix, that is if you go to your AVD (android virtual devices) edit the one that you are trying to run the app in and at the bottom you have a hardware section, all you have to do is press new on the right of that small box and from the properties drop down select GPU Emulation, and make sure you set it to true or “yes”, it works for me however there isn’t a way to navigate through the app using the soft keys atleast no yet

    so

    AVD > Edit Device> Hardware> New > Properties > GPU Emulation > true

    • mark shirley

      Cant find that selection of buttons – just about given up with this complex piece of rubbish its so annoying even when i can get it to work it doesnt render what you can see on a live device

  • http://twitter.com/lakhanir Rehan Lakhani

    However, pressing the esc button in the emulator makes the app go back one screen :) , hope this helps :)

  • Helen

    Excellent post! I wasted 1/2 of my day trying to this out.

  • Robin

    Thank you so much for this information, what a life saver!

  • http://www.facebook.com/david.c.faidella David Costa Faidella

    The Android team has released a fix in ADT 21:
    http://tools.android.com/download/adt-21-preview#TOC-Installation

  • Daniel

    Thanks to the tip of David, I installed ADT 21 Preview and the emulator is working like a charm. Here is how to do:

    1. Eclipse -> Install new software -> Add and then add this update site: https://dl-ssl.google.com/android/eclipse-preview/
    2. Now install all developer tools from this site, then restart Eclipse
    3. Open Android SDK Manager from the toolbar, or by running android-sdk-macosx/tools/android
    4. Go to Preferences, and check “Enable Preview Tools”
    5. Now install everything from “Tools (Preview Channel)”
    6. Restart Eclipse, and you can now start your emulator in cristal clear retina mode :-)

    Everything works, Navigation, Mouse, Drag, …, you can even move the emulator to a secondary monitor (mine is a iMac in Target Display mode).

    • :)

      Dude, you made my day. Thanks!

  • http://www.facebook.com/people/David-Hersey/767991612 David Hersey

    This post saved me lots of headbanging … welll actually I had already been banging :)
    Thank you so much, and +1 the shame on google.

  • Jimmy Ng

    thank you. thank you kotan and the commenters on this forum. You guys have saved me days of headaches!

  • Pingback: Retina下android模拟器无法运行的解决方法 | 51engineers.com