I'm using Eclipse to learn how the SampleSyncAdapter example works. I can't get my breakpoints to work. I set a breakpoint in multiple locations but none get hit. For example, AuthenticatorActivity.onCreate() never get's called. Anyone know why?
Thanks.
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.
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.
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
Following @Eric Woodruff answer I got this idea that I share for those who want a debugging session in Eclipse exclusively dedicated to the sync adapter:
1. Switch to DDMS perspective
2. In the device/emulator process locate :synch (see the picture)
3. Then click on the green bug button ( Debug the selected process: provided it's source project is present and opened in the workspace )
this works fine for me and give me a more realistic point of view:
android:process=":sync"
As given in other answers works great.
On top of that, if your call to ContentResolver.requestSync(mAccount, AUTHORITY, settingsBundle) has anything wrong with it, your service won't get called without any errors thrown.
You need to double check that the Authority string is matching in the manifest and xml, and java code. Also the Account object is created correctly with the right account type and added to the AccountManager using:
accountManager.addAccountExplicitly(newAccount, null, null)
(the variable names are named after the official android tutorial here: