Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Eclipse Configuration for Android | |
| 2 [TOC] | |
| 3 | |
| 4 Instructions on using **Android Studio** are [here](android_studio.md). | |
| 5 | |
| 6 *** note | |
|
dgn
2016/10/03 15:04:06
That's really neat! However I couldn't find the do
| |
| 7 This documentation was written for Eclipse 4.5 though other versions of Eclipse | |
| 8 should work similarly. | |
| 9 *** | |
| 10 | |
| 11 ## One time Eclipse Configuration | |
| 12 This section contains set up steps for the very first time you start Eclipse. | |
| 13 You should only need to go through these once, even if you switch workspaces. | |
| 14 | |
| 15 * Starting Eclipse. It can be started a couple of ways: | |
| 16 * From Ubuntu main menu, select Applications > Programming > Eclipse 4.5 | |
| 17 * From the command line, type eclipse45 | |
| 18 * Pick a workspace somewhere in your hard drive. | |
| 19 * Install CDT - C/C++ Development Tools | |
| 20 * Select Help > Install New Software... from the main menu | |
| 21 * For Work with, select mars - http://download.eclipse.org/releases/mars | |
| 22 (or any other mirror that seems appropriate) | |
| 23 * Check Mobile and Device Development > C/C++ Remote Launch | |
| 24 * Check Programming Languages > C/C++ Development Tools | |
| 25 * Click through Next, Finish, etc to complete the wizard. | |
| 26 * If you get errors about a missing dependency on org.eclipse.rse.ui for the | |
| 27 "C++ Remote Launch" install, add an available update path of | |
| 28 http://download.eclipse.org/dsdp/tm/updates/3.2 | |
| 29 * Click Restart Now when prompted to restart Eclipse | |
| 30 * Memory | |
| 31 * Close Eclipse | |
| 32 * Add the following lines to `~/.eclipse/init.sh`: | |
| 33 | |
| 34 ```shell | |
| 35 ECLIPSE_MEM_START=1024m | |
| 36 ECLIPSE_MEM_MAX=8192m | |
| 37 ``` | |
| 38 | |
| 39 ## General Workspace Configuration | |
| 40 These are settings that apply to all projects in your workspace. All the | |
| 41 settings below are inside Window > Preferences. | |
| 42 | |
| 43 * Android formatting | |
| 44 * Download [android-formatting.xml](https://raw.githubusercontent.com/androi d/platform_development/master/ide/eclipse/android-formatting.xml) | |
| 45 * Select Java > Code Style > Formatter from the tree on the left | |
| 46 * Click Import... | |
| 47 * Select the android-formatting.xml file | |
| 48 * Make sure Android is set as the Active Profile | |
| 49 * Java import order | |
| 50 * Download [android.importorder](https://raw.githubusercontent.com/android/p latform_development/master/ide/eclipse/android.importorder) | |
| 51 * Select Java > Code Style > Organize Imports from the tree on the left | |
| 52 * Click Import... | |
| 53 * Select the android.importorder file | |
| 54 * Disable automatic refresh. Otherwise, Eclipse will constantly try to refresh | |
| 55 your projects (which can be slow). | |
| 56 * Select General > Workspace from the tree on the left. | |
| 57 * Uncheck Refresh using native hooks or polling (if present) | |
| 58 * Select General > Startup and Shutdown from the tree on the left. | |
| 59 * Uncheck Refresh workspace on startup (if present) | |
| 60 * Disable build before launching | |
| 61 * Select Run/Debug > Launching | |
| 62 * Uncheck Build (if required) before launching | |
| 63 * File types for .gyp and .gypi | |
| 64 * Go to General > Editors > File Associations | |
| 65 * Add `*.gyp` and `*.gypi` file types, and associate them with Python Editor | |
| 66 * See http://pydev.org/index.html for instructions on getting a Python | |
| 67 Editor configured in Eclipse | |
| 68 * Enjoy a happy life with Ctrl+Shift+P and automatic matching bracket | |
| 69 highlight. | |
| 70 * Tab ordering | |
| 71 * If you prefer ordering your tabs by most recently used, go to General > | |
| 72 Appearance and check Show most recently used tabs | |
| 73 * Autocomplete | |
| 74 * Select Java > Editor > Content Assist | |
| 75 * Check Enable auto activation | |
| 76 * Change Auto activation triggers for Java: to | |
| 77 `._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ` | |
| 78 * Line Length | |
| 79 * If you want to change the line length indicator, go to General > Editors > | |
| 80 Text Editors | |
| 81 * Check Show print margin and change the Print margin column: to 100. | |
| 82 | |
| 83 ## Project Configuration | |
| 84 | |
| 85 ### Create the project | |
| 86 | |
| 87 * Select File > New > Project... from the main menu. | |
| 88 * Select C/C++ > C++ from the project tree and click Next. | |
| 89 * Note: not "Makefile Project with Existing Code", even though that sounds | |
| 90 sensible). | |
| 91 * For Project name, use something meaningful to you. For example | |
| 92 "chrome-android” | |
| 93 * Uncheck Use default location. Click Browse... and select the src directory of | |
| 94 your Chromium gclient checkout | |
| 95 * For Project type, use Makefile project > Empty Project | |
| 96 * For Toolchains use -- Other Toolchain -- | |
| 97 * Click Next | |
| 98 * Disable the default CDT builder | |
| 99 * Click Advanced Settings... | |
| 100 * Select Builders from the tree on the left | |
| 101 * Uncheck CDT Builder | |
| 102 * Click OK if a dialog appears warning you that this is an | |
| 103 'advanced feature' | |
| 104 * Click OK to close the project properties dialog and return to the project | |
| 105 creation wizard | |
| 106 * Click Finish to create the project | |
| 107 | |
| 108 ### Configure the project | |
| 109 | |
| 110 * Right click on the project and select Properties | |
| 111 * Exclude Resources (OPTIONAL). This can speed Eclipse up a bit and may make | |
| 112 the indexer happier. | |
| 113 * Select Resources > Resource Filters | |
| 114 * Click Add... | |
| 115 * Select Exclude all, Select Folders, and check All children (recursive) | |
| 116 * Enter .git as the name | |
| 117 * Click OK | |
| 118 * Click Apply to commit the changes | |
| 119 * C/C++ Indexer (deprecated, seems to be done by default)</span> | |
| 120 * Select C/C++ General > Indexer from the tree on the left | |
| 121 * Click Restore Defaults | |
| 122 * Check Enable project specific settings | |
| 123 * Uncheck Index source files not included in the build | |
| 124 * Uncheck Allow heuristic resolution of includes | |
| 125 * Click Apply to commit the changes | |
| 126 * C/C++ Paths and Symbols. This help Eclipse build the symbol table for Chrome. | |
| 127 * From a shell, run `GYP_GENERATORS=eclipse build/gyp_chromium` | |
| 128 * This generates `<project root>/out/Release/eclipse-cdt-settings.xml` which | |
| 129 is used below. | |
| 130 * Select C/C++ General > Paths and Symbols from the tree on the left | |
| 131 * Click Restore Defaults to clear any old settings | |
| 132 * Click Import Settings... The import dialog should appear. | |
| 133 * Click Browse... A file browser should appear. | |
| 134 * Select `<project root>/out/Release/eclipse-cdt-settings.xml`. | |
| 135 * Click the Finish button. The entire preferences dialog should go away. | |
| 136 * Right click on the project and select Index > Rebuild | |
| 137 * Java | |
| 138 * Create a link from `<project root>/.classpath` to | |
| 139 `<project root>/tools/android/eclipse/.classpath`: | |
| 140 ```shell | |
| 141 ln -s tools/android/eclipse/.classpath .classpath | |
| 142 ``` | |
| 143 | |
| 144 * Edit `<project root>/.project` as follows to make your project a | |
| 145 Java project: | |
| 146 * Add the following lines inside `<buildSpec>`: | |
| 147 ```xml | |
| 148 <buildCommand> | |
| 149 <name>org.eclipse.jdt.core.javabuilder</name> | |
| 150 <arguments></arguments> | |
| 151 </buildCommand> | |
| 152 ``` | |
| 153 * Add the following line inside `<natures>`: | |
| 154 ```xml | |
| 155 <nature>org.eclipse.jdt.core.javanature</nature> | |
| 156 ``` | |
| 157 | |
| 158 ### Run Robolectric JUnit tests | |
| 159 | |
| 160 * Prerequisite: Install a Java 8 JRE and make sure it's available in Eclipse | |
| 161 * Create a new JUnit test target: | |
| 162 * Run > Run Configurations > New launch configuration > JUnit | |
| 163 * Using Android JUnit test launcher | |
| 164 * Test tab: | |
| 165 * Run a single test or all tests in the package you want | |
| 166 * Arguments tab: | |
| 167 * VM arguments: | |
| 168 | |
| 169 ``` | |
| 170 -Drobolectric.dependency.dir=out/Debug/lib.java/third_party/robolectric | |
| 171 ``` | |
| 172 | |
| 173 * Classpath tab: | |
| 174 * Bootstrap Entries: | |
| 175 * Advanced... > Add Library > JRE System Library | |
| 176 * Select a Java 8 JRE | |
| 177 * User Entries: | |
| 178 * Add JARs... | |
| 179 * Select the following JAR files from `third_party/robolectric/lib`: | |
| 180 * `json-20080701.jar` | |
| 181 * `tagsoup-1.2.jar` | |
| 182 * `android-all-5.0.0_r2-robolectric-1.jar` | |
| 183 * JRE tab: | |
| 184 * Execution environment: Select the Java 8 JRE | |
| 185 * Run or Debug the launch configuration | |
| 186 | |
| OLD | NEW |