Android studio, debugging an infinite loop - android

I am trying to debug an infinite loop in my program in android studio. I have a lot of breakpoints set up but every time I try to run it, it gets to a point where it just says "The application is running" and stalls out until the phone runs out of memory. What tool in Android studio is there to see the flow of the program? Specifically what methods are being called and which one is being called ad infinitum.

To see your code execution stopped on breakpoint, you need to run it in debug mode Shift+F9. Normal run (Shift+F10) is not affected by breakpoints.
See this article: https://developer.android.com/tools/debugging/debugging-studio.html

Related

Android app runs very slowly after resuming from breakpoint

My Android app runs dead slow (almost frozen) after resuming from a Java breakpoint, even if I disconnect from the debugger or even unplug the USB cable. I get the same behavior on every device and emulator I've tried. Performance is great until it hits the first breakpoint, but it's unusable after I resume and I have to kill it. It's very frustrating.
It used to work great but it started with Android Studio 3.1.x and it's still happening after I upgraded to 3.2.1, then 3.3.2, the latest stable release at this time. None of my colleagues who work on the same app have this problem so it's probably not the code. I suspect I have a configuration issue somewhere.
I have no idea what changed when it started. It happens no matter where the breakpoint is. I don't see any errors in LogCat.
I'm using a MacBook Pro (15-inch, 2017) running OSX 10.13.6, Android Studio 3.3.2 (current stable release) and a Pixel XL running P. Also various emulators running P.
Any ideas or suggestions are much appreciated.
NOTE: It happens on Java breakpoints but not Kotlin.
NOTE: I cannot repro with a simple default app, so it's project specific, but only on my machine.
As #Magudesh stated, method breakpoints are very slow for the android debugger.
It's a lot more useful to just add a line breakpoint in the first line of your method and then (if it's necessary) in the last line.
That will greatly increase performance. If you then want to jump to the next breakpoint you can just hit the green play button in your debugger window.
make sure your debugger is ok .
Don't add breakpoint in the method definition. Method breakpoint will decrese the performance. Go with line breakpoint. That is better.
Please go through the difference b/w method breakpoint and line breakpoint if you are not aware.
Try to remove all the previous breakpoints that you might have added in Android Studio.
Go to the debugger window and select the View Breakpoints option and then disable all the old breakpoints and only add the new one which you want to use.

Find out what line of code my app is currently running in Android Studio's debug mode

When I'm running an app in debug mode with Android Studio, is there a way that I can find out what line of code is currently being processed? By this I mean, is there a tool that works kind of like setting a breakpoint, but you don't have to set a breakpoint - you can just find out at any point in time what line of code is being executed?
The reason for this, is that sometimes you may want to debug intermittent hangs in your app. If your running in debug mode, and your app hangs, it would be useful to immediately find out what line of code it last processed, without having to plan ahead by setting breakpoints or trace calls

Application in Android studio is stopping automatically while debugging

There is an app which i am running on android studio in debug mode. It is running fine and it stops at the breakpoint set, but when i press F6(Step Over) after the breakpoint i.e. Step Over again and again, it will execute till the end of that function and then stops the application and the debugger. But when i press F8(Resume prog) to resume the program, it works normally and even the functions after this breakpoints are called as expected and neither the debugger nor the application stops.
Any idea why it is happening in case of F6 only and not in F8?
Note:- Keymap is changed to Eclipse, so there is no point of shortcuts
in android f6 is not used for Debug please refer this key map for android studio here

Logcat window clearing immediately on run

When I run my android app, the logcat window fills up and then clears. I have System.out.println()'s that aren't showing up, nothing is showing up and I have no idea why.
EDIT: Using Android Studio
I have had a lot of issues with logcat in Android Studio, so here's a few items:
In your run configuration (just to the left of the play button, select "Edit Configuration" from the drop-down, you can configure a couple of options related to logcat, including whether or not Android Studio will clear it on startup
If the debugger disconnects you will lose your connection to the logcat. (some kinds of errors seem to force disconnect the debugger. I'm not entirely sure why.)
If you never clear your logcat, then Android Studio will attempt to display the entire logcat since the last time you restarted the device/emulator. This can take a long time, and may display a blank screen while it's processing.
By default, Android Studio will try to filter out messages unrelated to your app. In my experience, this never works right. I think it's easier to search for the tag that you're looking for.
I haven't specifically tried System.out.println() in Android Studio, but the typical Android way to print debug messages is with Log.d. Log
is located in android.util.Log. Android Studio will import it automatically if you type Log and press alt+enter.
My guess would be that your problem isn't that it's clearing logcat, but that it's not clearing logcat and Android Studio is choking on too large of a log file. Either select auto-clearing from the run configuration window or try walking away for a few minutes and see if the logcat ever comes back

Writing first Android app, stuck trying to simply run the Hello World tutorial

I'm new to Java, haven't used Eclipse in probably 2 years. We're starting up a mobile dev team at work, and I'm just going over the tutorials on the Android site:
http://developer.android.com/training/basics/firstapp/running-app.html
Simply just created a project, launched the virtual device manager, have that emulator running, then click Run -> Run as Android application in Eclipse .
I've been staring at this screen for about 5 minutes now:
It says "Launching (100%)" in the bottom right corner of eclipse, and this Progres window just says Launching, but the emulator isn't doing anything.
I know emulators are generally pretty slow... But is this normal or did I do something wrong?
That happened to me too, and still does at times:
Close the emulator and execute the program again
If that didn't work, execute the program while the emulator is running. A new emulator will pop up, close the old emulator
If that didn't work, delete device and create a new one.
Also, is there anything at all popping up on the Logcat view?
I would recommand checking the list of process afterwards. Sometimes when i brutally terminate an app in eclipse, the process is still running.
But i'm on PC and i use an older version. Maybe it has been fixed.

Categories

Resources