Eclipse Configuration for Android
Note: This documentation was written for Eclipse 3.7 although configuration for 3.8 and above should be very similar.
One time Eclipse Configuration
This section contains set up steps for the very first time you start Eclipse. You should only need to go through these once, even if you switch workspaces.
- Starting Eclipse. It can be started a couple of ways:
- From Ubuntu main menu, select Applications > Programming > Eclipse 3.7
- From the command line, type eclipse37
- Pick a workspace somewhere in your hard drive.
- Install CDT - C/C++ Development Tools
- Select Help > Install New Software... from the main menu
- For Work with, select indigo - http://download.eclipse.org/releases/indigo (or any other mirror that seems appropriate)
- Check Mobile and Device Development > C/C++ Remote Launch
- Check Programming Languages > C/C++ Development Tools
- Click through Next, Finish, etc to complete the wizard.
- If you get errors about a missing dependency on org.eclipse.rse.ui for the "C++ Remote Launch" install, add an available update path of http://download.eclipse.org/dsdp/tm/updates/3.2
- Click Restart Now when prompted to restart Eclipse
- Memory
- Close Eclipse
- Add the following lines to ~/.eclipse/init.sh
ECLIPSE_MEM_START=1024m
ECLIPSE_MEM_MAX=3072m
General Workspace Configuration
These are settings that apply to all projects in your workspace.
- Android formatting
- Java import order
- Select General > Workspace from the tree on the left.
- Uncheck Refresh workspace on startup (if present)
- Uncheck Refresh using native hooks or polling (if present)
- Disable build before launching
- Select Run/Debug > Launching
- Uncheck Build (if required) before launching
- File types for .gyp and .gypi
- Go to Window > Preferences > General > Editors > File Associations
- Add *.gyp and *.gypi file types, and associate them with Python Editor
- See http://pydev.org/index.html for instructions on getting a Python Editor configured in Eclipse
Project Configuration
Create the project
- Select File > New > Project... from the main menu.
- Select C/C++ > C++ from the project tree and click Next.
- Note: not "Makefile Project with Existing Code", even though that sounds sensible).
- For Project name, use something meaningful to you. For example "chrome-android”
- Uncheck Use default location. Click Browse... and select one of the src subdirectory of your Chromium gclient checkout
- For Project type, use Makefile project > Empty Project
- For Toolchains use -- Other Toolchain --
- Click Next
- Disable the default CDT builder
- Click Advanced Settings...
- Select Builders from the tree on the left
- Uncheck CDT Builder
- Click OK if a dialog appears warning you that this is an 'advanced feature'
- Click OK to close the project properties dialog and return to the project creation wizard
- Click Finish to create the project
Configure the project
- Right click on the project and select Properties
- Exclude Resources (OPTIONAL). This can speed Eclipse up a bit and may make the indexer happier.
- Select Resources > Resource Filters
- Click Add...
- Select Exclude all, Select Folders, and check All children (recursive)
- Enter .git as the name
- Click OK
- Click Apply to commit the changes
- C/C++ Indexer
- Select C/C++ General > Indexer from the tree on the left
- Click Restore Defaults
- Check Enable project specific settings
- Uncheck Index source files not included in the build
- Uncheck Allow heuristic resolution of includes
- Click Apply to commit the changes
- C/C++ Paths and Symbols. This help Eclipse build the symbol table for Chrome.
- From a shell, run GYP_GENERATORS="eclipse,${GYP_GENERATORS}" android_gyp
- This generates <project root>/src/out/Release/eclipse-cdt-settings.xml which is used below.
- Select C/C++ General > Paths and Symbols from the tree on the left
- Click Restore Defaults to clear any old settings
- Click Import Settings... The import dialog should appear.
- Click Browse... A file browser should appear.
- Select <project root>/src/out/Release/eclipse-cdt-settings.xml.
- Click the Finish button. The entire preferences dialog should go away.
- Right click on the project and select Index > Rebuild
- Java
- Eclipse should have generated .project and perhaps a .classpath file in your <project root>/src/ directory.
- Replace/Add the .classpath file with the content from Appendix I
- Edit <project root>/src/.project as follows to make your project a Java project:
- Add the following lines inside <buildSpec>:
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments></arguments>
</buildCommand>
Add the following line inside <natures>: <nature>org.eclipse.jdt.core.javanature</nature>
Appendix I: Eclipse class path file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="android_webview/java/src"/>
<classpathentry kind="src" path="android_webview/javatests/src"/>
<classpathentry kind="src" path="base/android/java/src"/>
<classpathentry kind="src" path="base/android/javatests/src"/>
<classpathentry kind="src" path="chrome/android/java/src"/>
<classpathentry kind="src" path="chrome/android/javatests/src"/>
<classpathentry kind="src" path="content/android/javatests/src"/>
<classpathentry kind="src" path="content/public/android/java/src"/>
<classpathentry kind="src" path="content/public/android/javatests/src"/>
<classpathentry kind="src" path="content/shell/android/java/src"/>
<classpathentry kind="src" path="content/shell/android/javatests/src"/>
<classpathentry kind="src" path="media/base/android/java/src"/>
<classpathentry kind="src" path="net/android/java/src"/>
<classpathentry kind="src" path="net/android/javatests/src"/>
<classpathentry kind="src" path="testing/android/java/src"/>
<classpathentry kind="src" path="third_party/cacheinvalidation/files/src/java"/>
<classpathentry kind="lib" path="third_party/android_tools/sdk/platforms/android-17/data/layoutlib.jar"/>
<classpathentry kind="lib" path="third_party/android_tools/sdk/platforms/android-17/android.jar"/>
<classpathentry kind="output" path="out/bin"/>
</classpath>
Is possible Android Debugging?