What is the bottleneck of Android app debugging? - android

I know there are many discussions about the emulator which is so slow that is essentially unusable for routine debugging tasks. I am talking about debugging with physical devices. My app runs about an order of magnitude slower in debug mode than in non-debug mode. I mean “an order of magnitude” literally. I can think of three possible candidates for the bottleneck:
Computer.
Android device.
Eclipse.
Checking my computer during debugging shows its quad-core CPU and 8 GB memory on Windows 7 Ultimate 64-bit has plenty of room left. The devices I use are Samsung Admire running Gingerbread, Airpad X running ICS (a generic tablet). My Eclipse is Indigo Service Release 2 Build id: 20120216-1857.
Could any experts, especially those who have successfully boosted Android app debugging performance offer some tips

not a solution , but a few tips that might make the problem a little less , well, problematic :
try to reduce the number of logs written at runtime.
you can run the app normally , and then debug it at runtime . simply choose the process via eclipse , and choose the bug-icon in the ddms view (not the one next to the launch-icon) .
same as #2 , but inside the code : use "waitForDebugger" when you see fit.
try to reduce the number of expressions that need to be evaluated in the debug mode.

Related

Emulator awfully slow on Windows 7

This is not a rant, and also not a duplicate of the forever "why is Android emulator so slow" problem. So, until a few weeks (maybe months) ago, emulating Android devices on my Win7 64-bit system was at the very least acceptable (x86 emulation was decently fast to be usable). However, trying to create any ("fast" "new" "2.0") emulator instances using the latest version of the SDK, platform tools, etc., is only a source of frustration and pain for several days now. I'm trying to understand if it's an issue on my side or people can actually use the latest version of the Android emulator included in the latest SDK, on Windows 7.
My PC config: Win7 x64 / Intel Core 2 Quad #3.8 GHz / 6 GB RAM / plenty of HDD space / dedicated GPU
What happens when trying to start an emulator with any API level, with either x86 or x86_64:
version 1) emulator starts, Android logo appears, glows for a bit, and that's it. It never reaches the Home screen. Emulator log shows absolutely no errors. Trying to connect using adb freezes Android Studio until I kill the emulator process.
version 2) Same like version 1, but in this case I can't even kill the qemu-system-i386 process (yes, not even with full admin rights). I have to actually restart Windows. Process remains a zombie, using 1 GB of RAM.
version 3) If I'm lucky, sometimes it reaches the Home screen, but becomes completely unusable. Sometimes I can click on things (maybe 2-3 clicks), and then becomes completely unresponsive. Occasional "Launcher has stopped" / "System has stopped" messages appear randomly in the emulator's home screen...
I've installed the latest Intel HAXM 6.0.3 version (the one downloaded by the Android SDK manager). Virtualization is enabled in BIOS.
I've tried all kinds of emulator options (more or less RAM, hardware vs software GPU, x86 / x86_64). Almost same result every time.
I've completely deleted and reinstalled the entire Android SDK and Android Studio.
CPU is not the issue - it's not under load while emulator runs.
Free RAM is not the issue - it's not fully used while emulator runs,
HDD is not the issue - I even defragmented it, and it's not looking like it's under any sort of load while emulator is running.
So, my question is very simple: is anyone out there using Windows 7, who can actually start up, let's say, a Marshmallow x86 emulator just by a simple 2-3 clicks process, and actually have it reach the home screen? Or does the "new, faster" emulator actually need some sort of super-powerful machine which I don't seem to possess anymore? The only thing that apparently changed was the HAXM driver. But it's stating that it has initialized just fine, so I don't know. Oh, and VirtualBox runs just fine. GenyMotion, by contrast, just flies. But I'd like to have the official Android emulator in a working state, or am I asking for too much?
Adrian, in my sad opinion: yes, you would need a powerfull processor, even a litle bit more of ram. The almost-aceptable scenario for you to run api 24 emulation in xxxhdpi resolution is an i7 with 8 of ram.
But this is what hard and software manufacturers want you for: upgrade, upgrade, upgrade. And it's not necessairilly true for you, or not obligatory for today. Maybe tomorrow...
It's my case too. I have a second generation i5 with 6 of ram and plenty of disk. Have a good geforce gpu too. And what I do to have my emulators running, or, how do I emulate in my win7? First of all: unninstalled all the last (about 30) non-security system updates from windows (! yes..., they make your system very heavy, the same with the various distributed c++ packages microsoft want us to carry on with our systems even if we use it once a year, or less - go to control panel and ripp'em off! Keep only the most recent c++ package - if you need it later, update again). Actually I'm even investigating what else "updates" I can delete from my system to have it usable again, mine again. Microsoft...
Second: enabling "power save mode" on your android studio (menu file), only in testing times, seems to make things faster.
Third: do heavy tests on emulators with "low" apis, like android 4 or 5 at max. And emulate devices with small screens or resolution, 5 pol. with 720 points (hor.), at max. If possible use _x86 64 emulation.
With this you can make it happen. The emulator is slow to load and open, but when running it works in a fairly good speed. First thing to do there: enter developer options and "force gpu" on both places. This will instruct your pc to take advantage of your dedicated gpu system.
Do not try to open two or more emulators at the same time, sorry.
When 90% of your debug is done (i do it in an emulator running android version lower than 5, normally 4.0 or 4.1 - 480x800 screen), then you pay the price to load a big screen, big dpi android 5, 6 or N). While it loads, make a coffee and use the bath.
When the beauty (beast?) is loaded, then do the final tests with all your apps that stayed waiting for this special moment. I maintain all my apps waiting for it. When I load the "big" emu I use this oportunity to do all tests I was needing - because it's not a simple task open this everytime I want.
In the future, as said: i7, 8ram, powerfull gpu and, very important: a good SSD drive (until 10x faster) to throw up damn nasty harddisk to the garbage. :) Best.
EDIT: when you create an AVD image with the latests APIs, Android Studio defines the ram and disk space values for the emulation and, in my opinions, these values are too big and too hard for the hostage computer to deal with. First point: your testing app never will demand all those resources. Two: your pc suffers hard to deal with a very fragmented Gb data from here to there, and there to here. Three: the virtual image created on your hard disk gets bigger with the use. So: 1 - lower the default values from your avd images, ram and disk sizes; 2 - on the avd launching window dialog, edit the options of each image and rip information everytime before start the emulation OR/AND 3 - uninstall your apps from the emu when not needed.

Is it good and possible to always test an android app on real device rather than using android emulator

I am trying to learn android on a dell device having 4gb ram and intel pentium chipset. I am trying to run hello world app on a emulator but it actually take much time(more than 5 minutes) to start the process and at the end give error message "Error while waiting for device: Timed out after 300seconds waiting for emulator to come online". As far as testing on device is considered i find it fast and easy.
So my question is that possible to always test an app on real device and skipping the testing on an emulator.
Also suggest me some tips to make my android studio run faster.
.
Its always better to test on a real device. Its very fast especially when debugging. If your emulator is taking long to load imagine a situation where you are trying to debug and want to check the app's behaviour after each change in code. Just install the usb drivers and sdk tool that your device's api version is running on
Sure it is!
First of all, enable the developer mode in your device (if it's not enabled already). Info for doing this here.
Then just plug your device via USB and it will appear when you run your project in Android Studio.
NOTE: The first time you attempt to run the project, your phone will ask for permissions, make sure you allow it!
It will be good if we are testing the application in real device rather than emulator if you have the device. But we can't buy different density, different dimension, different android version devices for testing so for that purpose we need to use emulator.
To improve the speed of android emulator install HAXM in your system, it will speed up the emulators.

Is Deploying A Mono Android App to Emulator Always Slow?

I am building a simple mono android project and deploying to the emulator. Every time I try to run my program it takes at least 30 seconds to a minute to deploy and start the app in the emulator. Further, simple things like single stepping and inspecting variables take several seconds. Is this normal?
Also:
Is it much faster deploying to an actual android device?
Is it much faster using java instead of c#/mono android?
If no, how does one efficiently program on the droid with such slow iterations?
My computer is no powerhouse but it isn't crap either: core 2 duo 2.6ghz, 4gb ram.
I faced with same problem too. But you can solved it in two ways (at least both these ways helped me):
Use MonoDroid on Mac. It deploys to emulator much faster.
Run your application in emulator with same Android version. I tried few different configuration and this one the fastest (as for me): application with android 2.1 and emulator with android version 2.1.1. For me it works pretty fast.
Is it much faster using java instead
of c#/mono android?
I tried java and yes, it deploys (not works) faster.
1) It is faster and more effective to test your program on an android device.
2) It isn't critical.
My hardware is like yours, I develop in Java, and have a wait time similar to yours.
I'm developing android applictions using monodroid and deploy takes ~10s.
Just deploy without close emulator.
I was closing it all times and it take 30sec-1min to deploy.
I did next and it helps a Little in speed:
MonoForAndroid 4.1 API level 16
Add to hardware 'accelerometer'
And set Device size Ram to 512 instead of 1024 (Will not start with accelerometer and ram 1024)
Emulator began work faster, not enough but it is better than nothing
The same issue is without Mono too.
You can run emulator with parameters:
emulator #my_avd -no-boot-anim -qemu -icount auto
where #my_avd -- launch a virtual device named 'my_avd'
The full answer by #Timothy003 is here: Why is the Android emulator so slow? How can we speed up the Android emulator?
Works fine for me, deploying is much faster.

Emulator to Physical

Emulator --- Device
Hey people. I'm not very experienced in Android development, so I would like to know what I have to expect.
I wrote an app of about 1000 lines of code, which is running perfectly fine in the emulator. So what will it be like when I install it on a physical device? Ain't got one here at the moment, but I will get my hands on one on the next days. Will there be a bunch of nasty errors? Just some design stuff? Errors, that cant be reproduced in the emulator?
Thanks in advance
EnflamedSoul
Note: emulator runs the real Android code. It emulates ARM device and runs the whole stack on top: linux kernel, libs, android code. It is the same as device sans some hardware (camera, mobile network stuff, gps) and much slower.
So what will it be like when I install it on a physical device?
Will there be a bunch of nasty errors?
No problems really. It should work ok.
Just some design stuff?
If you set your emulator to the same resolution and pixel density of your device, then it should look identical.
Errors, that cant be reproduced in the emulator?
There ares some thing that you can not do in emulator: primarily make calls and use camera. Otherwise emulator behaves like a plain phone.
My Android apps have all been very simple, but I have really only had to make small changes to their layouts when I tried them on my phone. Over-all, the process of moving to the phone was a rather painless one.
I had a code that took 4 minutes on the emulator to complete, and on the real device it is just 10 seconds.

Speed up Android emulator

I read on many other topics that the Android emulator starts really slow. Indeed, it takes +15 mins to start. However, on my machine is slow even after that.
The 'phone' responds with a 3-4 seconds delay and everything has a huge lag.
Is there any way to improve the performance of my laptop (Asus 1201N) is too rusty for the Android emulator?
PS: Tried in different emulator resolutions and the result is the same
Edit: My laptop has 2 cores with HyperThreading. And it shows as 4 CPU in Device Manager. However, when using the emulator, just one of the graphs is at 100%. Can I do something to make it work multi core?
Do you have "Disable Boot Animation" checked?
Also, if that doesn't fix it, one thing that helps is that you never actually have to close the emulator screen while you're coding. If you click debug when it's already open, your APK will get uploaded to the emulator and start pretty much immediately. For some reason it took me a while to figure out that I didn't have to manually close the emulator.
One thing I learned that helped me is that once the emulator is open from your first debug run you DO NOT have to close it. Leave it open, and on your next debug run it will be ready to go without any load up time like when you first open it.
In regards to your slowness after startup I suspect it's just your computer. It runs very fast for me. It starts up in about 20 seconds or less, and once it's open my subsequent debugs load very fast.
I hope at least my first tip helps to save some of your sanity.
Here's what you can try. It does speed up the emulator for me, especially during loading time.
I noticed the emulator is only using a single core of the available CPU. What I did is to set it to use all available processors.
I'm using Windows 7.
When the android emulator is starting, open up the Task Manager, look under the Process tab, look for "emulator-arm.exe" or "emulator-arm.exe *32" ...right click on it, select Processor Affinity and assign as much processor as you like to the emulator.
I think there is few ways to improve the performance of your Android Emulator like
Use Snapshot, this will improve the boot time for consecutive application running
Use x86 Intel Hardware Accelerator
Use 3rd Party Emulator like BlueStacks
Hopefully it will help you to improve the performance and resolve your problems.
Thanks
I had the same problem and in order to solve it I just disabled all the transition animation effects that are enabled under Spare Parts.
it is way too slow for me too.
(slow on both my Pentium 4 (ubuntu) and my dual core 64 laptop (Windows 7)
apparently it uses QEMU - could I perhaps look for the image file and try a different version of qemu?
Another thing I tried is this: http://www.android-x86.org/ (in vmware)
this seems MUCH faster but I can't get it to see the network!
(right now I just want to test some websites in the brower so seeing the network is a must - I'm not doing native apps just yet)
I discovered that instead of running the 'Debug' target, I just run the 'Run' target. The emulator runs a lot smoother when doing so. I only jump into debug mode if I really need it.
To connect to network from android-x86, you neek to manual setup ip manual by use this command in console mode (Alt + F1):
ifconfig eth0 netmask 255.255.255.0 up
after do that, you can check it by type : netcfg in console and you can see this ip is set at your local wmware
you can check it success by ping ip you had been set in command prompt, and after that, you can use adb connect to connect debugger to your virtual android

Categories

Resources