Wednesday, November 30, 2011

Building the ADT Plugin for Eclipse

ADT Plugin Revisions

Notes about successive releases of the ADT Plugin can be found at
Currently the last revision is ADT 15.0.1 (November 2011)
Usually ADT Plugin has dependencies with SDK Tools (located at <sdk>/tools directory of sdk). So do not forget to check the dependency and update to corresponding SDK Tools version after updating ADT Plugin.

Getting the ADT Plugin Sources

You can follow instructions from

In total you should perform the following sequence of commands:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl --insecure --proxy krsuls001:8080 > ~/bin/repo
$ chmod a+x ~/bin/repo
$ repo init -u -b android-4.0.1_r1
$ repo sync sdk

After this sdk project will be downloaded to your WORKING_DIRECTORY. You can list all available branches:

$ git branch –a

and also switch to version you need, for example ADT 15.0.1:

$ git checkout remotes/aosp/tools_r15

android-2.3.7_r1 sources contain ADT 0.9.9 release
android-4.0.1_r1 sources contain ADT 14.0.0 release

Buiding the ADT Plugin from Android Source Tree under Linux

First of all you should get the whole Android Source Tree (see details at
Then you should get Eclipse RCP (
Build Plugin:
  • WORKING_DIRECTORY – directory with Android Source Tree
  • eclipse_plugin – destination directory for plugin
$ . build/
$ lunch sdk-eng
$ export ECLIPSE_HOME=~/eclipse
$ ./sdk/eclipse/scripts/ ~/eclipse_plugin/

In case of successful build you get the something like in eclipse_plugin directory.

Building the ADT Plugin with Eclipse under Windows

First of all get the sdk source code necessary version. You will also need some libraries from android/prebuilt.
Then check that you have "Eclipse Plug-in Development Environment" installed in Eclipse.
In Eclipse right click in the Workspace and choose "Import...", then select "Existing Projects into Workspace". You need to import the following projects:
  • sdk\eclipse\plugins\
  • sdk\eclipse\plugins\
  • sdk\eclipse\plugins\
  • sdk\eclipse\plugins\
  • sdk\eclipse\plugins\
  • sdk\eclipse\features\
  • sdk\eclipse\features\
  • sdk\eclipse\features\
  • sdk\eclipse\features\
  • sdk\eclipse\sites\external
  • sdk\androidprefs
  • sdk\assetstudio
  • sdk\common
  • sdk\ddms (import all 3 projects - ddmlib, ddms-plugin, ddmuilib)
  • sdk\hierarchyviewer2 (import app, hierarchyviewerlib)
  • sdk\ide_common
  • sdk\layoutlib_api
  • sdk\rule_api
  • sdk\sdkmanager (import sdklib, sdkuilib)
  • sdk\sdkstats
  • sdk\swtmenubar
Define two User Libraries:
-    ANDROID_JFREECHART (add the 3 jars under android/prebuilt/common/jfreechart)
-    ANDROID_SWT (add the 3 jars under android/prebuilt/common/eclipse and android/prebuilt/windows/swt/swt.jar)
Some projects have ANDROID_SRC and ANDROID_OUT_FRAMEWORK Classpath Variables. Actually you could add requested jar files as “External JARs”.
To create *.jar file from sources:
-    Right click on Project
-    Select “Export”
-    Java -> JAR file, press Next
-    Select the export destination for JAR file

Note 1: You can face with the following error during modifying the project properties:

Remove the windows hidden attribute that is set on the .classpath file. This should fix the error.

Note 2: For adt-overlay project, to fix the error:
C:\workspace_tw\adt-overlay\build.xml:285: srcdir "C:\workspace_tw\adt-overlay\src" does not exist!
Just create empty folder adt-overlay/src.

Note 3: If there are compile errors such as:
The method addBooleanArg(String, boolean) of type RemoteAndroidTestRunner should be tagged with @Override since it actually overrides a superinterface method
check  the Project Properties -> Java Compiler -> Errors/Warnings settings.
You can disable project specific settings or just change setting for Annotations->”Missing @Override annotation” from error to warning.

Once you get rid of all compile errors you could either run/debug ADT in Eclipse or export plugin for installing with Eclipse Plugin Manager.

Run/debug ADT Plugin:

-    Just run adt project as "Eclipse Application"
-    Another copy of Eclipse will start were you can check you plugin functionality.

Export ADT Plugin:

-    Select external-site project
-    Open site.xml
-    Hit the “Build All” button

Add the following files and directories under external-site project directory to


Now you can use as independent plugin.

Android LogCat filter in Eclipse

Very often during development we need to filter messages in LogCat View. Logcat Message Filter Settings already allow you to filter logs by Log Tag, Log Message, by PID, by Application Name and by Log Level. But sometimes it is not enough.

Fortunately log filter accepts Java regular expressions.
For example, to match only two tags we can use the following expression in Log Tag field:


Sometimes you need to exclude some messages from Logcat. In old ADT versions it could be done with creating new logcat filter when filtered messages were deleted from main log.
In ADT 15.0.1 such functionality was changed and filtered messages stay in main log.

And also Java regular expressions can help to get rid of annoying messages:
To exclude tag  “dalvikvm” from log:  (?!dalvikvm\b)\b\w+

DDMS LogCat still has some issues in spite of regular updates of ADT and SDK Tools. One of the most known is about small log buffer that requires to press “clear log” button periodically.

This issue and many others are solved in open source tool android-log-viewer developed by Mikhail Lopatkin:

  • Display logs from a device or an emulator
  • Display saved logs and dumpstate files
  • Search in the logs using regex if needed
  • Bookmarks
  • Filter log lines by tag, PID, log priority, message content
  • Filtered lines can be hidden, highlighted or shown in a separate window
  • Display any avaliable buffers: main, system, events, radio
  • Save filtered lines
  • Display process list