Slashdot Mirror


Android Needs a Simulator, Not an Emulator

An anonymous reader writes Jake Wharton, Android Engineer at Square, has written an article about one of the big problems with building apps for Android: developers need a simulator for testing their software, rather than an emulator. He provides an interesting, technical explanation of the difference between them, and why the status quo is not working. Here are the basics of his article: "A simulator is a shim that sits between the Android operating system runtime and the computer's running operating system. It bridges the two into a single unit which behaves closely to how a real device or full emulator would at a fraction of the overhead. The most well known simulator to any Android developer is probably (and ironically) the one that iOS developers use from Apple. The iPhone and iPad simulators allow quick, easy, and lightweight execution of in-development apps. ... There always will be a need for a proper emulator for acceptance testing your application in an environment that behaves exactly like a device. For day-to-day development this is simply not needed. Developer productivity will rise dramatically and the simplicity through which testing can now be done will encourage their use and with any luck improve overall app quality. Android actually already has two simulators which are each powerful in different ways, but nowhere near powerful enough."

31 of 167 comments (clear)

  1. x86 Android Virtualisation: native performance! by thatkid_2002 · · Score: 5, Informative

    Android is available for x86 these days and you can use hardware acceleration (CPU and GPU). Just set it up and get near-native performance. Or if you have an Android phone just `adb install -r blah.apk` what more can you want?

    1. Re:x86 Android Virtualisation: native performance! by Lordpidey · · Score: 2

      Android is available for x86 these days and you can use hardware acceleration (CPU and GPU). Just set it up and get near-native performance. Or if you have an Android phone just `adb install -r blah.apk` what more can you want?

      One that works on most CPUs.

      --
      Some people encrypt by using rot-13 twice. I prefer the more secure method of using rot-1 a total of twenty six times.
    2. Re:x86 Android Virtualisation: native performance! by thegarbz · · Score: 3, Interesting

      I think what the author is referring to is an Android system which integrates into the tool chain and can be directly controlled by the tool chain / IDE.

      Yes the android debug bridge exists, but it's quite a beast to use and I don't believe the authors comments refer to a problem of simply running an app on a phone.

    3. Re:x86 Android Virtualisation: native performance! by cerberusss · · Score: 4, Informative

      "Just set it up" isn't as easy as you make it out to be. I just tried it in Android Studio.

      First, you have to install a 3rd party kernel extension (from Intel). Then you have to configure an AVD with the new x86 value for the CPU/ABI field. It didn't appear for some reason for my target "Android 4.4.2". After looking around, I found another download in the Android SDK Manager called "Intel x86 Atom System Image", let's download that. The documentation mentions this, but I glossed over it. OK, back to the AVD manager and create a virtual device.

      Now I finish it, and run the app. Running the app takes 39 seconds, as Grails reports (about 5 seconds, if that, on Xcode for the iOS port of our project). It asks where I want to run it, pick the new AVD and click Run. It starts Android but not the app.

      Weird. OK, so I run it again with the simulator running. The option "choose a running device" cannot be selected. That's strange. I pick the new AVD again and unfortunately, it starts another copy. Shit. I let it boot but notice it's really slow as usual -- ten minutes later it's still booting. I check the already running copy and click around. Slow as hell as well. Apparently it's not accelerated at all!

      At this point, I'm ready to give up and go back to testing on a device again.

      The above is tested on a 2013 MacBook Air with 8 gigs of memory.

      --
      8 of 13 people found this answer helpful. Did you?
    4. Re:x86 Android Virtualisation: native performance! by The1stImmortal · · Score: 4, Informative

      How about Genymotion? http://www.genymotion.com/ - uses VirtualBox as the underlying x86 VM layer, instead of AVD + HAXM. Supports a few additional sensors too (either emulated or passed through from real hardware if it has them)

    5. Re:x86 Android Virtualisation: native performance! by sheltond · · Score: 3, Informative

      Yes. Genymotion is great.

      Really fast, lots of different system images for different Android versions and device configurations (screen sizes and densities, input devices, etc), integrates nicely with adb and Eclipse (I haven't tried it in Android Studio, but I imagine it works equally well).

    6. Re:x86 Android Virtualisation: native performance! by Lawrence_Bird · · Score: 2

      Wow.. dude you are lame ok? HAXM is an option in the SDK. Is it that difficult to check the box? And creating an AVD is not exactly rocket science. I use IntelliJ (as opposed to Android Studio which came out later) and have had no issues with emulation. In fact I often have a physical device and one or more emulators attached to ADB. And one click to build and send to the 'device' isn't too hard either. On any modern PC the x86 emulator runs without a hitch.

      As to your "issue" with an emulator not appearing - this can sometimes happen in IntelliJ (and probably A.Studio too) when the machine has come out of sleep. It is not an issue with the emulator, rather the ADB and IntelliJ not communicating.

  2. So much wrong by Anonymous Coward · · Score: 3, Interesting

    Apple's simulator is unusable because it's a simulator. If it works on the simulator it tells you virtually nothing. If it doesn't work on the simulator it tells you virtually nothing. You need to run on the actual device. Oh what I wouldn't give for an emulator where if it ran on the emulator it would be some guarantee to run on the real device too, and if your code doesn't run on the emulator it would be some guarantee your code was broken (not that the simulator just doesn't support some feature).

    So yes, let's applaud Apple's cheap-ass simulator approach which is unusable, and emulate it [heh] on Android.

    1. Re:So much wrong by JaredOfEuropa · · Score: 4, Insightful

      Virtually nothing? I'd say that the simulator covers about 95% of my testing and diagnosis needs. I only have to resort to running on a physical device when I have to test stuff related to the on-board sensors, camera, or push notifications. So far I've found 1 case where the simulator did not behave as expected. If it works on the simulator, chances are it'll work on the device. If it doesn't work on the simulator, in almost all cases you will be able to use the simulator to diagnose and fix the issue. I should note that I do not do game development; I've no experience in writing apps with high performance 2d/3d graphics.

      With that said, I always test release candidates on various types of real devices.

      --
      If construction was anything like programming, an incorrectly fitted lock would bring down the entire building...
    2. Re:So much wrong by coinreturn · · Score: 4, Informative

      I should note that I do not do game development; I've no experience in writing apps with high performance 2d/3d graphics.

      Well, then, when you try doing those things you'll understand why my comment is true.

      Well, I won't. I have five games in the App Store and I have always used the simulator for development. It works very well. For me, it is VERY rare that something works on one while not working on the other.

    3. Re:So much wrong by JaredOfEuropa · · Score: 2

      That's a fair point. However, to what extent do these issues exist because the iOS simulator is a simulator rather than an emulator? An emulator might have broken OpenGL support, same as the simulator. And for performance-related stuff I'd prefer a real device over either.

      By the way, the author of that article does not IMHO make a strong point for simulators. He seems to have a lot of problems with the Android development environment, some related to performance and reliability but many related to usability, and the reason the emulator has these problems is not the fact that it's an emulator. An equally crappy simulator isn't going to solve those problems.

      --
      If construction was anything like programming, an incorrectly fitted lock would bring down the entire building...
    4. Re:So much wrong by coinreturn · · Score: 3, Insightful

      Bullshit. [snip] The simulator is entirely useless for developing an actual app.

      No, what I said is not bullshit. In my experience, it works great. Yours differs. That does not make my experience bullshit. Perhaps you suck at programming.

  3. Re:simulator? by Anonymous Coward · · Score: 2, Informative

    You clearly need to get your terminology straight.

    What you describe as a "bridge" is more like a house for homeless people.

    But simulator is the correct terminology... the way you might want to implement it doesn't make any difference.

  4. Surrprised it is so hard by MichaelSmith · · Score: 2

    Android apps already run on Linux. Why can't I just fire them up on Ubuntu? The VM should br portable.

    1. Re:Surrprised it is so hard by StripedCow · · Score: 2

      Perhaps if your PC runs on an ARM processor, it would be simple.

      I'm not sure Ubuntu has an ARM iso.

      --
      If Pandora's box is destined to be opened, *I* want to be the one to open it.
    2. Re:Surrprised it is so hard by c · · Score: 2

      Perhaps if your PC runs on an ARM processor, it would be simple.

      ARM emulation under x86 is feasible. Google "libhoudini". Whether it's simple is another question, but the pieces are there.

      --
      Log in or piss off.
  5. Desktop integration by Anonymous Coward · · Score: 5, Insightful

    Given the open source nature of Android, what I don't understand is how no project so far has integrated the Android runtime with the Linux desktop. Licencing issues maybe? Leave it in a separate PPA.

    It would be amazing to be able to run Android applications in Linux seamlessly, ideally integrated with the indicators and notifications provided by the OS.

    That would be a killer feature (and would expand the library of games available for Linux by 1,000,000%), in addition to other applications.

    I know it is possible to emulate Android, there are some options for this, but it is not about emulating a phone in my computer; I already have a phone. What I would love is to run Android apps in it (of course, as long as that software includes x86 libraries, or there is an emulation layer available).

    1. Re:Desktop integration by Mister+Liberty · · Score: 2

      Guess the project of your dreams needs a Summer of Code at Google.
      Propose, propose, propose...

    2. Re:Desktop integration by tlhIngan · · Score: 2

      I always wonder the same. But probably the answer is Canonical wants its own Linux phone than powerful integration with Android. Should be, in current days, a killer flag: "hey, my Linux distro runs Android apps, and integrates smoothly with Android phones".

      Well, the problem is Android.

      You see, the current Andorid OHA agreement makes it impossible for an OEM that ships Android phones to ship any other phone that can run Android apps that does not run Android. So if you make an Android phone, you're blocked by Google et. al. from releasing a Firefox OS or Ubuntu phone if they can run Android.

      So Mozilla and Canonical know they physically cannot support Android at all, because if they do, the number of people who can sell and release the phone dwindles dramatically. There just aren't that many companies that make pure AOSP phones or non-Android phones.

    3. Re:Desktop integration by grouchomarxist · · Score: 2

      Actually that was the goal of the AndroVM project. Unfortunately, that project became the commercial Genymotion project and the goal doesn't appear to be desktop integration, but instead a developer tool. You can use it to run apps, but I don't see any specific integration features.

      Otherwise, there is BlueStacks, but it runs on Windows and Mac, but not Linux.

  6. Re:Emulator? Simulator? Pfffttt... by kav2k · · Score: 3, Insightful

    Great. Now, do you have a spare tablet around for every target android version?

  7. I just use a real Android device by rklrkl · · Score: 4, Insightful

    Whilst playing around a little with Eclipse and the Android SDK, I found it much easier to just plug in my Android tablet (or it could be an Android phone or both) and download/run the app on that. You get to check rotation, multi-touch, camera etc. a lot more easily this way and it's just as easy (if not more so) than running the emulator. Of course, there could be Android devs without any Android devices at all, but I suspect that's a tiny minority.

    The main use of the emulator is probably just to test different screen dimensions render OK - I personally wouldn't use it during the bulk of development though.

    1. Re:I just use a real Android device by GNious · · Score: 2

      I have my jolla development set up to simply send any program I working on straight to a phone, and run there as part of the compile+run procedure.

      With SSH access, QTCreator is basically SSH'ing in, deploying+running the app, and giving feedback straight back to my screen, while I have a separate shell running with SSH into the phone and while I'm reviewing the behaviour of the app directly on the phone.

      No need for simulators, emulators or other -mulators :)

    2. Re:I just use a real Android device by Threni · · Score: 5, Informative

      Yes. You can step through the code on your device from your pc. (Even if connected over wifi. Which is nice, when it works, but it's a little flakey. It's solid over USB though).

  8. Re:It always did seem odd to me. by Anonymous Coward · · Score: 2, Informative

    Very much in Android, including application code, is not Java.

  9. Re:Emulator? Simulator? Pfffttt... by Anonymous Coward · · Score: 2, Informative

    Great. Now, do you have a spare tablet around for every target android version?

    This is the general problem with Android in any case, since versions are not kept up to date on all devices, not all devices have the same resolution, CPU capabilities, graphics performance, input devices, cameras, accelerometer, GPS hardware, touch screen capability, keyboards, and so on and so on.

    You will always need to test on the actual hardware to be sure your monster Intel box and nVidia video cards aren't giving you a false idea of how fast your app is, or that your app doesn't suck, or that it'll work with a particular device.

    If you need hit over the head with a clue bat, ask Roxio how they do it for Angry Birds testing.

  10. Re:simulator? by dmbasso · · Score: 2

    Did you read the article? He defines simulator as a layer between the application and the OS.

    I didn't RTFA, but let me point out that his definition is one way to implement a simulator. Let me summarize it for you:
    Simulator: functionality, what it does.
    Emulator: function, how it does.

    A simulator mimics the real thing but isn't.

    Both do it, only the objectives are different.

    --
    `echo $[0x853204FA81]|tr 0-9 ionbsdeaml`@gmail.com
  11. Toooooo Slooooow by EmperorOfCanada · · Score: 3, Interesting

    I have a bonkers fast machine with SSD, gobs of memory, CPUs on fire, etc. Yet running the android emulator is go off and make a sandwich time.

    I do 100% of my testing on actual devices which is not at all how I work with iOS. With iOS I only occasionally test my code on an actual device as there are occasional differences between the simulator and the actual devices.

    Also the android is all about settings, settings settings, instead of asking me if I have a keyboard, GPS, etc. What I would like is a list of the most popular phones. Then I could try out my code on those very phones. Also it would be great if someone had a problem with my app on a specific phone and I was able to quickly select that phone and try out my code.

    I get a feeling that the emulator was not so much aimed at developers of apps but aimed at hardware and OS developers who need this magically perfect emulation. Whereas the iOS Simulator is quite clearly aimed at people who are developing apps. Which oddly enough would be 99.999% of the potential audience.

  12. The resistance to this idea is surprising by iPaul · · Score: 4, Interesting

    As I read the comments I find it surprising that people somehow object to this idea because 1) they don't like the terminology, 2) the say the existing emulator is just fine, 3) Apple sucks, 4) If you just do these 37 steps, it works awesome on my machine and 5) did I mention Apple sucks?

    I don't program professionally but I am a tinkerer and I did try my hand at both iOS and Android development. As a noob in both, I found the Apple environment much easier in terms of usability. This is not a plug for Apple, but an observation about how fast the tool chain is able to launch the simulator and step into live, running code. There are obviously things that won't work, but I was able to get going quickly and play with the examples. It was also relatively painless (although there was a lot of hoop jumping) to get the code onto my phone and running.

    I like the Jet Brains based Android development environment. It's really nice to work it but when it comes to actually running the code you wrote, you basically need a real device. The emulator start up time is horrible and the performance while running is terrible. I've tried to get the x86 ABI running on my machine but I didn't notice much of an improvement. Yes, yes, I know, but Apple sucks. I would call the emulator borderline unusable for development and almost not usable for testing because of its bad performance.

    I'd like to try some of the resources he mentioned in the article, but I only found out about them two minutes ago when I read the article. As a noob, I didn't even know they existed. Tools do matter. As Microsoft and Apple have found out, creating really nice development environments is important in capturing mind share. At some point every developer is a noob at something and making easier for the noobs to get going is part of making a platform sticky.

    So let the grammar corrections, the Microsoft sucks, the Apple sucks comments come. It doesn't change the fact that being productive isn't just about which APIs you can memorize, but also about the toolchains and environments you use to write code.

    --
    Leave the gun, take the cannoli -- Clemenza, The Godfather
  13. Re:Even Firefox OS has a simulator by rjstanford · · Score: 2

    Actually, you don't really need much of the FirefoxOS when doing the design job since the HTML/CSS will render with Firefox quite exactly as it would in any FirefoxOS phone.

    What, both of them?

    --
    You're special forces then? That's great! I just love your olympics!
  14. Re:Emulator? Simulator? Pfffttt... by master_kaos · · Score: 2

    And what really sucks is that sales on android are 15% of what is on iOS anyways, yet testing is 10x more on android vs apple. We have about 10 apps in apples app store, and we only have are 2 flagship apps on android. We don't bother testing on every device, I'll test on 3 separate devices and a bunch of emulator configs. Once in a while we get a negative review of "crashes on device x running y" but nothing we can do except refund because we arent blowing out our brains buying every device, nor do we have the funds to.