Android Studio - Can't see "evaluate logs" set on breakpoint - android

I'm just trying out new debugging techniques and wanted to replace my log statements with breakpoints that can log out stuff for you.
I tried to follow techniques like https://medium.com/mobile-app-development-publication/debug-without-using-temporary-log-in-android-studio-91d9394a1e94, where you right click on the breakpoint in the gutter then set the logging in there.
The issue is I cannot find any of the log statements.
I can confirm I am hitting the breakpoint (when I choose to make the breakpoint suspend).
I think it might be due to the new logcat in Dolphin version of Android Studio?
Does anyone know how you can see log statements in breakpoints?

Related

Android Studio doesn't show exceptions

I have a problem. Android Studio doesn't show exceptions. Instead of this application hangs and AndroidNotResponding dialogs appears. But Android Studio logcat shows nothing. For example, if I have a NullPointerException in my program, it will not be shown but ANR dialog will appear. How can I repair this and catch my exceptions.
Make sure you have Android Monitor set properly in Android Studio. In the top-left corner, select the correct device. Then select the proper log level, preferably Error in this case. And the on the far-right select No Filters.
disconnect phone and reconnect usually help me: log reappears in logcat
also check no filter is applied.
also changing filter helped me in past.
other solutions is debug. check where it crash and wrap with try/catch and inspect Exception.
other solution is use Fabric.io (https://fabric.io/) : maybe is overkilling but found it very useful
ok, I've found solution. It was because of GoogleAnalitycs. No exception was shown because of this line
mTracker.enableExceptionReporting(true);
If you have the same problem just comment this line and everything will work.

Unable to set breakpoints in Android Studio

I am working on Ubuntu 14.04, AndroidStudio is 1.2.1.1. I am able to build the app, click on the "Debug" icon and launch the app. I can see logcat output and I can pause the app from the debugger. The one thing I cannot do is set a break point. I tried clearing the cache, restarting AS, right clicking in the file where I want to set the break point. None of these produce the desired effect. This is a well-hidden feature.
I also had this same issue in Android Studio, where I couldn't set breakpoints. This is what I was doing wrong: I was clicking on a line that didn't have any code in it, or a line that contained a comment. As soon as I clicked on a line in method/class, it allowed me to set the breakpoint.
There shouldn't be any problems setting break points if you follow the process outlined here
If you are running into some issues, here are a few steps to get you started:
- Use a Log.d() in your app and see if it outputs to the logs. If it doesn't then you know you are not in debug mode.
- Are you debugging on the device or the emulator? If the device, you need to enable development. I would suggest to select "wait for debugger" to make sure it's attached before you run the code.
This should be pretty straightforward. Let me know what you find out.
To add a line breakpoint, proceed as follows:
Locate the line of code where you want to pause execution, then either click the left gutter along that line of code or place the caret on the line and press Control+F8 (on Mac, Command+F8).
If your app is already running, you don't need to update it to add the breakpoint—just click Attach debugger to Android proccess . Otherwise, start debugging by clicking Debug .

How to debug android codes after loops in Eclipse

I have found my app returned error after a for loop.
Are there any tricks for me to just run through the for-loop and then debug?
I have studied some posts saying that using Ctrl+R could help.
However my latest version eclipse cannot found such a function.
You can do Step debugging in Eclipse
mark a break point in the code where you want ( mark at the blue line as shown with a small blue circle)
then run->Debug Configuration and start the app
and when the program starts it will stop at that line where you put break point.
just dont forget to change from JAva or DDMS to Debug
also you can see various stepping code things in run menu while debugging
I hope it helps you
1.use Log.i() or System.out.println() to print something.
2.just see debug information in logcat
3.reduce loop times or replace loop with other simple code, then run the app again

Locating Errors When Developing Android Apps

I'm working on my first Android app and to be honest I'm not sure about most of what I'm doing. Right now I'm stuck on a NullPointerException that is created by a line that refers to another class that, in turn, refers to another class.
How can I locate the error?
The word you are looking for is debug. If you are using eclipse, it's very easy to debug your program in most cases. Two main options in eclipse are to use the logger for debug prints to logcat, or debug the program step by step to detect relevant errors. Here is a tutorial for both options and here is a nice video tutorial in YouTube regarding debug in eclipse.
You can use the Eclipse debugger to help with that. Set a break point above the line that errors out and deploy your app using the Eclipse debugger (with the little bug icon) rather than the standard deployer (the play button). You'll be able to see what is going on right before the line with the error occurs and hopefully fix things up.
If that doesn't work, you can post the stack trace and your method that has the error and we can take a look at it.

Android - Having a hard time debuging Eclipse

I am a little bit new to developing for Android using Eclipse (Coming from a .NET/Visual Studio background).
My biggest problem in developing Android app is "debugging" them. Every time the emulator throws an error, there is no message, no explanation of what caused the error. I basically have to keep doing trial/error until something works.
My question is: Is there a better way to analyze the error messages that emulator shows (basically some stack trace about Dalvik)!
Also, is it possible in Eclipse [when debugging] to move the debugging cursor backwards to re-evaluate a variable or "skip" some lines of code?
Use LogCat view to see error/debugging messages. Regular console is of very limited help. Window->Show View->Other->Android->LogCat There on the top you will see some round buttons that basically can filter log from V (verbose) to E (error). You can't copy/paste from theLogCat window but you can save selected output to text file
Regarding the error messages (I'm assuming these are the messages that show up in LogCat): I've found that analysing the error messages and working your way up the list until you reach code that is yours is the most effective way to work. Frequently (for me at least) the emulator will crash and break somewhere in the OS code (which you probably don't have the source for) but you can follow the LogCat messages back to your code and start to see where the problem is. The crash may appear to happen in the OS code, but the original cause is typically you passing something wrong to the OS.
Regarding going backwards in code: nope, at least not with the my Eclipse Ganymede install
Regarding skipping code: When your in debug mode under the Run menu you can select "Step Over" (skips going into a method) , "Step Return" to exit a method and "Run to Line" in addition to setting Breakpoints by right clicking. This causes the code to run, but you aren't single stepping through it. Otherwise the only way to "skip" lines of code is to comment it out. I believe you can also change the value of variables in the debugger, but I've never tried personally. This may give you the desired effect.
Try closing all unrelated project, switch off eclipse and then do a clean and build for the project in picture.

Categories

Resources