Constantly, I have to debug with Android open source code, to use some private APIs or to test some hidden features.
Just follow the instructions from http://source.android.com/source/building-devices.html, make sure to get the vendor binaries at first https://developers.google.com/android/nexus/drivers.
It's also important to use correct software versions, e.g. Java 6 or Python 2. I haven't tried to find the best method to manage multiple java or python implementations, just on my most dirty way.
adb reboot bootloader to get into the boot loader, then unlock it with
fastboot oem unlock, and flash AOSP with
fastboot -w flashall.
adb push superuser.zip /sdcard/ adb reboot bootloader fastboot boot recovery.img
After the full build and flash, you don't need to build the full platform again, just build the specific module with
After that, use
adb to push the built library to /system/lib/
adb root adb remount adb push $BUILD_DIR/target/product/flo/system/lib/libstagefright.so /system/lib/
Then just hack the platform!