Eclipse stepping into class in android - java

I have a simple android project that I am trying to debug inside of Eclipse. When I run it in debug mode and use the "Step Over" button, it frequently seems to want to go into Android code (I don't want it to do this, just as a C debugger will not go into libc). I get a screen that comes up which looks similar to:
Class File Editor
Source not found:
The JAR file blahblah/android.jar has no source attachment.
You can attach the source by clicking attach source
I don't want it to go into Android or Dalvik code at all
(even if I could install source code) I am only interested in my own personal code.

not sure if it works for Android, but for Java SE you can set Step Filtering in the preferences to avoid stepping into some package/class:
Window -> Preferences -> Java -> Debug -> Step Filtering
Mark "Use Step Filters", add the packages and classes to ignore, mark "Step through filters".
Eventually you need to turn off the "Suspend execution on uncaught exceptions" to avoid the debugger stopping in case of an exception:
Window -> Preferences -> Java -> Debug

Depending on how you "step" you may be run through some platform/SDK code while moving between Activities even if your code seems to be running clean. To work around this I set a breakpoint somewhere within the next Activity and step through the current Activity and then once I hit the end of the code I hit resume and it breaks in my next Activity skipping any code that is not mine. Not the most elegant, but it works for me.
In Debug you will always be run through the exception handling platform..

In Eclipse:
F5 = go into; F6 = jump over; F7 = go upwards: F8 = go to next
breackpoint or exit
I always use it like this and never had a problem. :)

Related

IntelliJ IDEA: ClassNotFoundException if run Debug, execution/run does work

I have a Java Maven Project started in Eclipse, worked on it a few days, then imported it in IntelliJ IDEA, again working on it a few days.
The normal Run/Execution in IDEA and via shell does work, but not the Debug.
When I click the Bug Icon for Debug, it opens up URLClassLoader.java file and points on the Line "throw new ClassNotFoundException(name)" and pauses the Debug, if I click Resume Debug, it shows several Classes that do not belong to my project. I can click the Resume Button endless, it shows the same classes, also ClassNotFoundException over and over again in a continuously loop and does not debug my source.
If I click Build -> Rebuild Project it says at the Debug icon
"Hot Swap failed
myClassname: schema change not implemented;
myClassname: Operation not supported by VM"
In the Debug window under Variables it says: "Frame is not available"
The Debug of this project in IntelliJ IDEA did work previously, whats wrong now?
Looks like you have an exception breakpoint on ClassNotFoundException. Please try to open Run | View Breakpoints... and uncheck the breakpoint under "Java Exception Breakpoints".
in my situation, just neglect the evaluate language drop down.
This is really helpful. Go to your breakpoints in debug mode and make sure to deselect all the breakpoints first and then select only the ones in your class.

Is there a way to use breakpoint in eclipse android, the same we use breakpoint in Visual Studio or Netbeans?

I have tried to use breakpoint in the same way we use break point in Visual Studio or Netbeans, we simply mark the break point and when statement executes, the breakpoint highlights and we can see the values in respective data structure or variable using breakpoint explore.
As far as i have used eclipse, i have found break point is there too, but it is not in that way, means on runtime it does not pick the respective point and neither i can see values nor the application works perfectly while doing that. Is it not possible in eclipse or some tool is required, or i am wrong, please guide.
Ctrl+Shift+B while on the line.
Double click on the left most bar in Editor View.
Right click > Toggle Breakpoints on the left most bar in Editor View.
put a breakpoint at you code line you want,
then right click on project-> debug as -> android application
then go to window menu -> show view -> other... -> debug
or as show bellow
You must set a breakpoint and run the application in debug mode.
You have to launch application in Debug Mode. You can find Debug button left to Run button. It has bug as an icon.
Also could be useful: Setting up a Device for Development. It describes how to enable debugging on your device

Start Eclipse's Java debugger line by line without breakpoints

A nice thing that you can do in Visual Studio is to start your program and stop it to debug in the very first line, just by pressing F10 for line by line debugging. This is extremely useful when writing sample code or trying something new.
Is there a way to do this in Eclipse for a Java program? You can't start with line by line because that option is not enabled until you actually start debugging.
I know I could set a breakpoint at the very first line, but then I would have to remove it to actually debug something else.
bounty: for exact answers to the question (if it is even possible) and not a workaround.
The debug configuration for each program has ab option/checkbox “stop in main”. This will do what you describe.
http://help.eclipse.org/indigo/topic/org.eclipse.jdt.doc.user/tasks/tasks-java-local-configuration.htm
The "stop in main" mentioned by Holger is to be declared in a launched configuration:
The problem is to call that specific configuration from a keyboard shortcut, especially when this isn't always the last one you just launched
(if it were, you could use the shortcut "Run last launched" Ctrl+F11).
You can assign a shortcut to open the "run configurations" window, but then you need to select the right configuration to launch.
Or you can assign a true shortcut to a specific launch configuration, which is closer to what you are after, but that need an additional plugin ("Practically Macro")

How to remove disable breakpoints I did not set?

While debugging I get breakpoints from code that is not mine and for breakpoints I have not set.
Either it seems to come from libraries included or from java source code somehow.
Example:
Question:
This is really annoying. I can not find a way to disable these breakpoints and I keep pressing Resume constantly to move on.
How can I remove them or disable them? The breakpoint tab shows only my breakpoints available to be skipped or deleted
You can unset the following parameter in Eclipse:
Window -> Preferences -> Java -> Debug -> Suspend execution on uncaught exceptions

Eclipse + breakpoints = nothing happens

I'm trying to use Breakpoints in Eclipse, but when I set them - nothing happens.
Really.
For example in MVS when the program reachs breakpoint it stopps and I can see variables.
How to use breakpoints in Eclipse in the same way?
you need to be debugging the program, click the little bug next to the run button instead of said run button
First select Debug perspective as:
Then set Breakpoints at places you want:
After that create a Debug configuration via Debug As->Debug Configurations... and then Debug as Android Application as shown below:
Then in Debug perspective you can trace/watch value of your desired variable by pressing F8:
That's it, you can also evaluate expressions through Expressions view. If it is not enabled select it from:
Window->Show View->Other->Debug->Expressions.

Categories