SampleSyncAdapter Breakpoints Not Working

The SyncAdapter thread of execution occurs in a spawned background process, not in the process of your application itself, which is what you have your java debugger attached to.

Simple and ugly way: log() is your friend.

Better way: Start by looking at Debugging a service and find if that needs to be adapted for this case.


I had this problem and the solution was quite simple. As said before, the SyncAdapter runs on a different thread so you need to point the debugger to this thread. On Android Studio you add (code below) inside the SyncAdapter class:

android.os.Debug.waitForDebugger();

When you're debugging your app the sync adapter service won't be running automatically, so you have to start it and then target that process.

Attach debugger to Android Process (It's an icon next to the green bug)

It should work just fine


Actually, a sync adapter runs in the process in which it is configured. The documentation suggests setting android:process=":sync", but that is only a suggestion. For debugging you can always remove this line.

For Android Studio + Gradle, you might consider adding a debug version of the manifest in src/debug/. Turns out that the Gradle plugin is unable to merge in just the android:process attribute so you need to define the service and provider in src/release/AndroidManifest.xml and src/debug/AndroidManifest.xml separately so there is no merge conflict.