Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Breakpoint in service not working

I am trying to add a breakpoint to a service running on a separate thread. No matter where I place the breakpoint in the service, they are always ignored.

I am sure that the service is running as I see the Log.e in the logcat. My debug mode is also correctly used as any breakpoint in the main thread of the app works.

Am I missing something? Is debug mode not supported for services in a separate thread?

I just updated Eclipse and Android SDK tools to the latest versions today.

I am testing my application on a device.

like image 599
Rynardt Avatar asked Nov 26 '12 09:11

Rynardt


People also ask

Why is my breakpoint not working?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.

How do I fix breakpoint in Visual Studio?

To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.

How do you run until breakpoint?

Just press c. It will continue execution until the next breakpoint.

Why does Visual Studio not stop at breakpoint?

This problem occurs because ASP.NET debugging isn't enabled on the application.


2 Answers

The android.os.Debug.waitForDebugger() did the trick. Add this before the line of code you want to debug.

like image 82
Rynardt Avatar answered Oct 13 '22 23:10

Rynardt


Make sure that you declare the package name in the service tag in the manifest using android:process attribute, for example:

<service android:name=".YourCoolService"
            android:process="your.package.here"/>
like image 45
Gal Rom Avatar answered Oct 13 '22 23:10

Gal Rom