Setup IDE

Setup your choice of ide for entire AOSP development
AOSP includes a helpful package to do the job called IDEGen, which contains a series of scripts that will traverse your built sources and generate the project files. Yes, I said built sources…you have to build the target image first! There are several generated classes (AIDL stubs, resource files, etc.) that are needed to satisfly many of the cross-references.
The project has a handy README that explains all the details, but here it is spelled out:
source build/envsetup.sh
lunch aosp_x86-eng #(or pick your favorite lunch target)
make
mmm development/tools/idegen/
development/tools/idegen/idegen.sh
The first three steps just ensure that you have a built image ready…
The next step is to build the IDEGen module. This is the process that will fail if you don't have the proper intermediates in place first. Finally we run the generator script, which can take a few minutes to complete as it traverses the entire source tree.

What are you left with?

The root of your AOSP tree will now have three new files in it:
  • .classpath (Eclipse)
  • android.ipr (IntelliJ / Android Studio)
  • android.iml (IntelliJ / Android Studio)