This document describes how to build all the Eclipse support for Android, as well as how to configure all the source code such that you can edit, run and debug the Android plug-ins from within Eclipse.
If you happen to rebuild the tools (tools/base or tools/swt), then you should do the following from the command line in order to refresh the bundled dependencies inside the Eclipse plugins.
$ cd $ANDROID_SRC
$ rm -r out/repo
$ ./tools/gradlew -b tools/build.gradle publishLocal
$ ./tools/gradlew -b sdk/eclipse/build.gradle copydeps
Run and Debug
There should already be a couple of run configurations defined (adt and monitor). If you try to run/debug and execution fails with the message
then follow the accepted answer in http://stackoverflow.com/questions/17527096/eclipse-kepler-startup-error-noclassdeffounderror-org-eclipse-swt-widgets-disp (e.g. edit the run config, find the swt plugins in the plugins tab and make sure the one you need is selected).
You should now be able to run the ADT - it will invoke a second instance of Eclipse, where all the Android tooling is baked in. The first thing you need to do is point the tool to a version of the SDK. Open the Preferences panel, and in the Android panel go to the text field where you can point to an SDK root. If you have downloaded versions of Android in the past, you can point to the root containing all of the different platforms here.
After a brief pause you should now see a platform listed in the listbox in the Android panel, and it will identify itself as version "AOSP". If you instead point to officially released versions of Android, you'll see versions like "5", "6" and "7". The reason we don't use a number for the trunk version is to prevent you from accidentally building an app compiled against this trunk version, and then releasing it on the market.
Now that you have your Android versions configured, you can create a new Android project. Do New > Android Project, and in the New project dialog, you need to go and choose the AOSP platform in the platform listbox. Fill out the dialog. The only trick is that it asks you for a "Min SDK Version", and here you should again type "AOSP". You can now go and try for example the Layout Editor, by opening res > layout > main.xml.
We're working actively on the layout editor, but as you can see we could use help in lots of areas, from feature development, to icon work, to bug fixing, to bug reporting!
To stay up to date, just go to the command line, type "repo sync", wait for a while, and then redo the make steps (source build/envsetup.sh, lunch sdk-eng, make sdk, create_symlinks), and reopen Eclipse and rebuild all. If you get a build error, you can wipe out the entire out folder to build from scratch, but I rarely have to do that.
You can add additional Android platforms, such that you can choose which platform to use for WYSIWYG rendering (just like you can already switch theme, orientation, etc):
This is a new feature added just in the last couple of days. It lets you target older platforms but visually work with newer platforms, and quickly switch between them to see how your layout looks on different platforms. Of course, to use this you need to point your root Android tree to an install containing multiple platforms. If you do add additional platforms, make sure you copy older platforms (android-6, android-7, etc) into the platforms/ folder of the newly built SDK, rather than the other way around. This is necessary because the directory structure changed recently.
Now that you can build and run, let's take a look at the source code. The main Eclipse project to look at is the "adt" project, which is the Eclipse plugin.
First, you can configure your editor to use our custom dictionary to help the spell checker recognize words that are in our comments but are not in the default Eclipse English dictionary. Search for Spelling in the options dialog, and add sdk/eclipse/dictionary.txt as the "User Defined Dictionary" path.
Second, if you will be doing any editing of the source code, make sure you configure your editor to use our formatting preferences and our import order. Open the Java Code Style dialog, and for the formatter, import development/ide/eclipse/android-formatting.xml . For Organize Import, import development/ide/eclipse/android.importorder . The code style for the Android source code base is document in http://source.android.com/source/code-style.html.
That's it! You should now be able to get the source code, build, edit, run and debug the Android IDE tools!
Build Overview >