It is possible to compile the app via Eclipse, however, it's complicated because each app requires an ad hawk approach. I prefer to have my entire AOSP build code imported to Eclipse and then debugging the code is much easier.
First, you need to add your entire platform code: You have a full explanation here: http://source.android.com/source/using-eclipse.html
Basically this is what you need:
1) File->New->Project->Java Project
2) Uncheck "Use default location"
3) Choose the location of your entire AOSP build
4) Press Next (this will take several minutes)
Now you want to remote-debug apps in Eclipse:
1) Run->Debug configurations...
2) Click on "Remote Java Application" on the right side
3) Press "New"
4) Pick a name (any name will do)
5) Choose the project: pick your AOSP project
6) Use port 8700
7) Press Apply
Now you can debug any application in your AOSP (including the AOSP itself):
1) in DDMS view press on the Calendar process (for example)
2) Run->Debug Condigurations...-> Choose the new Remote Java Application you created and press apply
3) An error box will appear: "Errors in workspace", but you can ignore it (press "Proceed")
4) Go to Debug view and add any breakpoints you need
That's it...
If you need to debug the app during its onCreate
phase then you need to go to:
Settings app-> Developer Options-> Select debug app (choose your app)
and check "Waiit for debugger"