Difference between running a program in Android emulator and physical device? - android

I'm starting the studies about android development with Android Studio and I was wondering if it's possible to build applications only running code on a physical device or do I need to emulate others devices in order to avoid errors, etc.?
The Android Studio emulator barely runs in my machine, so I need to know if it is essential for the apps development or if there are other alternatives.

If you need to run on different versions of Android, just what #CrazySports101 mentioned, but also test different screen sizes & resolutions to check UI responsiveness, it would be better to use emulators.
Obviously, you can start development using either a single emulator or physical device, but during your final testing stages, it would make sense to use emulators to test all your device specific usecases.
And yes, there are few limitations with using an emulator, like it cannot emulate network connectivity, other real-time data, such as GPS, sensors, battery issues, etc. Or usecases such as calling, receiving SMS is not possible as well.

If you have a physical device, you can just use that. No need to run the emulator at all. An emulator is mostly used because it is convenient and easy to test different versions of android. For example, some libraries/UI component may behave differently on different phones.
It is better to use a physical device if your app is using radios like Bluetooth etc.

If you just started to learn android studio and your device can barely run emulator, I would recommend you to go for physical device. Emulator makes you possible to try your product on different version of android and screen ratios, but you can not emulate network connectivity, real-time data, GPS, sensors, battery issues, calling, receiving SMS is not possible. But if you are trying to launch a product in a market you should go for emulator as you would need to try your product on different versions as well.

Related

How can I test my app for a specific device?

I am building an application with React Native but the app not working well on a few android devices. So I need to see what's going wrong but I don't know how to set up an emulator for a specific device. Are these problems depends on phone's brand and model or it just depends on their android versions?
Its not really possible. There's two major problems:
Software. Real devices don't ship pure AOSP like runs on the emulator. They add patches and features and there's no way to know what they actually run.
Custom UIs. Many phones provide custom UIs like TouchWhiz and the like which can override Android behavior
Hardware. If your app depends on things that are very hardware specific, like GPS or Camera, they could have issues due to hardware bugs.
If you just want to emulate a specific OS version like KitKat, or specific low memory conditions its possible via emulator configuration. If you really need to test on a device, either buy one or use a service that allows you remote control over specific devices. Amazon has a nice device farm that you can rent over AWS.
One of the biggest challenges when developing for Android is the wide variety of devices and "optimizations" manufacturers make to their Android versions.
The Android emulator is based on AOSP (vanilla Android) and was only recently published with Google services included. This is the most clean version of Android. You can use the emulator to test UI scaling for different screen sizes but it will always behave like an AOSP Android. Google packs a bunch of hardware configurations into Android Studio which you can simply select when creating an virtual device. You can always create a custom hardware profile with custom screen size and resolution. Some manufacturers also change the DPI value of the OS causing the UI to be bigger or smaller, keep this in mind when creating a custom hardware configuration.
Further, you can use the emulator to test the default behaviour on different Android versions. Again, manufacturers change their Android usually causing slightly different behaviour.
I assume that your question is focussed on different behaviour of e.g. Samsung phones having crashes only occuring in Samsung phones (Samsung can be exchanged with any other brand here). Unfortunately, there is no simple way to test this but getting your hands on the faulty device. One option is to use a cloud based test lab (e.g. Firebase Test Lab, App Center or AWS device farm) to test your code on the faulty device or rent the device at a local shop. Most bigger cities have companies renting phones and tablets on a daily or weekly basis.
In the end you will need if statements checking for a specific device, manufacturer or Android version or any combination of them and doing something slightly different to fix the undesired behaviour.
I know that this is not the answer you are looking for, but it's the best I can offer. To tell a little tale of my worst experience: I had once a bug were calling a crypto function caused a kernel panic on HTC (?) phones. This means the user opened my app and the phone rebooted. I was required to implement the entire encryption logic again just for HTC with Android 6.0.

Where can I run into pitfalls when using an Android emulator over a real device for app development?

I want to get into developing apps for Android because of its large userbase. However, at the moment I do not have a smartphone. I'm also not too keen on getting an Android phone in the future.
What problems could I encounter when developing apps for Android solely using an emulator? I could use my parents' Android phones for the occasional testing, but will an emulator prove sufficient otherwise? Furthermore, is it possible to set up an Android Virtual Device with low-end hardware on my computer to test out apps with low-end phones?
note0: I do not plan on developing apps which require use of the phone's sensors (such as gyros, GPS, etc.) I only plan on developing apps which require internet access for API calls and perhaps microphone usage (I can't give away too many details right now ;) )
note1: I know this question has been asked before on stackoverflow (albeit 4 years ago). However, I feel it is important to revisit the question because emulators, hardware, and Android itself have changed enormously in the last few years.
edit: My main issues are problems like the app looking weird on the phone despite it looking fine on the emulator or working slowly on the phone but working fine on the emulator. Will every app which works fine on the emulator work fine on the phone as well with a similar hardware configuration as the emulator? I'm in particular targetting devices with Android 4.x/5.x.
Without a doubt, the biggest problem is that many functions like push
notifications, maps, geo-location, in-app vending etc. cannot be
tested with an emulator. The reason is that all these functions are
present in the Google Play Services library which is not present on
emulators.
Another important reason for testing on hardware devices is that the
OS implementation is changed by manufacturers like Samsung, HTC and
others, and therefore, certain problems & exceptions are not observed
till a real device is used.
But the most important reason has to be that running apps on an
actual phone is a hell of a lot more fun that it is with the painfully
slow and retarded emulators! One of the most important things about
Android is that anybody with an Android phone can easily explore
computer science concepts by running simple programs on their phone.
It is incredibly easy, even for a novice, to just fire up their
Android device and start exploring the world of programming! Till just a few years back, it was incredibly difficult to debug an app on a Symbian or Palm or WinCE device. iOS is still as retarded when it comes to running the simplest apps, you have to create a provisioning profile to run a Hello World app on an iPhone!
EDIT:
If your processor supports Intel virtualization, then the emulator can be made to run as fast as a real device. You need to check that out. If your PC is low-end in the sense that it does not support such virtualization, then running and testing Android apps will be a painful, tedious experience that will suck all the fun out of the development process.
Emulators do have one significant advantage over real devices - an emulator is able to access web services on a localhost. If you are still in development phase on your local server and have not yet shifted to a publicly hosted environment, the emulator can easily access web services on a local server. All you have to do is put your computer on the same network as the local server and you're good to go. A real device cannot access a localhost; its impossible, as far as I know.
The Android emulator is a true emulator - it emulates sensors as well, so in fact you can test sensor programming (with some limitations) on an emulator. It cannot do things like GPS, maps etc. because those features have been migrated to the Google Play Services library, and they require a valid Google account to be used, which is why that library is not present on an emulator. If you only plan to work with web services, APIs', GUIs' then I suppose an emulator is more than sufficient. Unlike the iOS simulator, an Android emulator generally exhibits the WYSIWYG behavior, so your GUI will not differ on actual devices, although you do need to test your GUI on multiple AVDs' with different screen form factors.

Developing an Android phone app -- can I use an Android tablet to test it on?

I've developed a couple of Enterprise iOS apps for our users in the field. Some have expressed a preference for Android devices over Apple, and I fully understand. I do not have an Android phone, nor do I want to get one and have a second account to maintain. I'm wondering if I can use an inexpensive Android tablet to reliably test an application that will ultimately be running on an Android phone? The app will need to communicate via internet to a server via cell connection or wifi.
Also, any advice for an Android newbie developer would be appreciated.
Yes you could test on a Android tablet but it would be hard to see how it render on a phone.
You could also use the Android Emulator to test different size and android configuration.
Yes. I developed my first major Android app using only a couple of cheap tablet devices. It's fine; the only thing you can't really test is "what happens to my app when a phone call comes in." Plus if you can get the emulator working under HAXM, or some other similar setup where it doesn't work like a tortoise trapped in amber, you can test on a variety of simulated devices perfectly well.
Other things to consider:
You'll probably want to test your app on a variety of different hardware and Android versions, in particular I'd recommend testing on older devices. This means that you friends' old Android phones are a great source of cheap test devices. I regularly gather phones from friends that would otherwise just end up lingering in the back of a drawer as a "spare" that will never actually get used. Bear in mind that you can use all the features of a phone apart from the actual phone bit without a SIM, including a WiFi-based data connection.
You may find that you can find good, contract-free "pay as you go" phone SIMs. I use a provider whose "credits" don't expire, so I have a phone connection for my test devices where there's no ongoing cost, apart from the actual calls I make when testing.

Testing Android apps on device

What is the recommended way of testing an app on a device? The emulator is slow, mostly unresponsive and a cpu beast on my machine, so I use my phone to test my app. When I make a change to code, Eclipse builds it automatically, and then I debug it on the device. Is this the most efficient way to test small changes in code?
Android has some information on testing here. Personally I've found that testing code is much faster on a device. Other options without a device is to use something like Android x86 and run it in virtual environment like VirtualBox - this can be faster than the emulator. In my opinion, to really make sure your application is working as expected (especially with graphics and memory usage) is to test with the device(s) you intend to deploy the application on.
That's how I test my code, the emulators and on an actual device are the only ways I know of. I usually use an actual device, but I think you can keep an emulator running to speed up time a bit, but not too much.
It's in my opinion a good way to check the general functionality of your application. If everything works fine, I would use the emulator to check with different versions of android/screen sizes/resolutions etc. Maybe you can ask a friend who has a more powerful PC. The best possible thing is of course that friends/family/relatives etc. own Android devices so you can test your application / let it be tested on real devices.

Do I need a Android phone for creating android applications?

I started developing android applications. And am testing with the android emulator. Do I really need android phone before releasing it for public usage?
Short answer No. You can test and build a android application package with the SDK and an emulator. But I would say there are usually many things which it would be wise to test on a device.
Personally I have noticed that the emulator does not give a good indication of response times for UI controls. It is usually necessary to move functionality which has long processing times into background threads to maintain user interactivity without the 'force close' pop-up. Testing the effectiveness of your UI responsiveness must be done on a phone to be meaningful.
Network connectivity is another aspect which can be vastly different on a phone, 3G or wifi.
Device sizes and Android platform versions can be tested effectively on the emulator.
Some phone allow hot-swapping of the SD card (replacing the SDcard without turning off the phone). I am not sure how to replicate this on the emulator.
There may be many more things which may only become apparent when using your application on a real device. I would strongly suggest to always test under real conditions when feasible for any commercial project.
From a technical perspective there's no reason why you can't develop purely on the emulator. You're not going to be able to test on every available device, so there's always going to be possibility of device specific bugs that you've missed.
However, I'd strongly recommend getting an actual phone to test your application on.
For me the biggest difference between an actual device and the emulator is the difference between using the interface with your fingers and using a mouse. Interactions which make sense in the emulator sometimes don't work as well when you start using touch on the screen. So if you develop purely on an emulator you'll won't lots of little improvements to your UI that would obvious when you used your app on a phone.
You can't feel a real app in your hands until you have a real phone. (I'm telling you as an Android developer)
So, developing w/o real phone is possible, but real phone gives you a lot more experience, fun & usefulness.
It depends on what type of application you're developing, for serious ones you need at least one device to test it on. For complex applications you would need a range of devices, for example with or without hardware keyboard, different navigational button etc. For basic, simple applications you'll probably do fine with just the emulator.
I would imagine with games you would definitely need to test on real devices.
Thanks to you all. I am going to get HTC Legend and test it, so that I can hope that my apps can be used by others :)
You guys suggest me HTC Desire or HTC Legend?

Categories

Resources