Chromium Android开发的Eclipse配置
單次的Eclipse配置
這一節包含第一次啟動Eclipse時需要的設置步驟。你應該只需瀏覽這個部分一次,即使你切換了workspaces。
-
啟動Eclipse。它可以通過如下的兩種方式啟動:
- 在Ubuntu的主菜單,選擇 Applications > Programming > Eclipse 4.5
- 在命令行中,輸入 eclipse45
-
選擇你硬盤上的某個位置作為 workspace。
-
安裝CDT - C/C++ Development Tools
- 從主菜單選擇 Help > Install New Software...
- 如果用的是Eclipse的mars版的話,選擇 mars - http://download.eclipse.org/releases/mars ( 或任何其它似乎合適的鏡像, 如neon http://download.eclipse.org/releases/neon )
- 選中 Mobile and Device Development > C/C++ Remote Launch
- 選中 Programming Languages > C/C++ Development Tools
- 一路點擊Next,Finish 等等,來結束向導。
- 如果你在安裝 “C++ Remote Launch” 時遇到了關于 org.eclipse.rse.ui 的missing dependency 錯誤,則添加一個可用的更新路徑http://download.eclipse.org/dsdp/tm/updates/3.2。
- 當提示重啟 Eclipse 時點擊 Restart Now。
-
內存
- 關閉 Eclipse
- 將如下的幾行添加到 ~/.eclipse/init.sh:ECLIPSE_MEM_START=1024m ECLIPSE_MEM_MAX=8192m
通用 Workspace 配置
有一些設置應用于你的 workspace 的所有工程。下面的所有設置都在 Window > Preferences里。
-
Android格式化 (formatting)
- 下載 android-formatting.xml
- 在左邊的配置樹中選擇 Java > Code Style > Formatter
- 點擊 Import...
- 選中 android-formatting.xml 文件
- 確認 Active profile 已經被設置為了Android
-
Java import 順序
- 下載 android.importorder。
- 在左邊的配置樹中選擇 Java > Code Style > Organize Imports
- 點擊 Import...
- 選中 android.importorder 文件
-
禁用自動刷新 (automatic refresh)。否則,Eclipse將時常地去刷新你的工程(那可能會比較慢)。
- 在左邊的配置樹中選擇 General > Workspace
- 如果選中了的話就反選 Refresh using native hooks or polling
- 在左邊的配置樹中選擇 General > Startup and Shutdown
- 如果選中了的話就反選 Refresh workspace on startup
-
禁用 build before launching
- 選擇 Run/Debug > Launching
- 反選 Build (if required) before launching
-
.gyp 和 .gypi文件類型配置
- 選擇 General > Editors > File Associations
- 添加 .gyp 和 .gypi 文件類型,并將它們與 Python Editor關聯。
- 參考 http://pydev.org/index.html 的說明在Eclipse中配置 Python Editor。
- 通過 Ctrl+Shift+P 和自動匹配 bracket highlight 來享受快樂的生活吧
-
Tab ordering
- If you prefer ordering your tabs by most recently used, go to General > Appearance and check Show most recently used tabs
-
自動完成
- 選擇 Java > Editor > Content Assist
- 選中 Enable auto activation
- 修改 Auto activation triggers for Java: 為 ._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
-
單行長度
- 如果你想要修改單行長度指示器,則選擇 General > Editors > Text Editors
- 選中 Show print margin 并將 Print margin column: 修改為 100。
工程配置
創建工程
- 在主菜單選擇 File > New > Project...
- 在工程樹中選擇 C/C++ > C++ 并點擊 Next。
- 注意:不是 “Makefile Project with Existing Code”,即使那聽起來不錯。
- 關于工程名 (Project name),使用一個對你來說有意義的名字。比如 "chrome-android”
- 反選 Use default location。點擊 Browse... 并選擇你的 Chromium gclient目錄的src 目錄。
- 關于工程類型(Project type),使用 Makefile project > Empty Project。
- 關于 Toolchains 則使用 -- Other Toolchain --
- 點擊 Next
- 禁用 默認 CDT builder
- 點擊 Advanced Settings...
- 在左邊的配置樹中選擇 Builders
- 反選 CDT Builder
- 如果出現了 這是一個 ‘advanced feature’ 的警告對話框就點擊 OK。
- 點擊 OK 關閉 工程屬性對話框 (project properties dialog) 并返回工程創建向導 ( project creation wizard )
- 點擊 Finish 創建工程
配置工程
-
在工程上右鍵點擊鼠標并選擇 Properties
-
排除 Resources (可選的). 這個可以加快 Eclipse 一點,并可能使indexer更開心。
- 選擇 Resources > Resource Filters
- 點擊 Add...
- 選擇 Exclude all,選擇文件夾,并選中 All children (recursive)
- 鍵入 .git 作為名字
- 點擊 OK
- 點擊 Apply 提交修改
-
C/C++ Indexer (deprecated, seems to be done by default)
- 在左邊的配置樹中選擇 C/C++ General > Indexer
- 點擊 Restore Defaults
- 選中 Enable project specific settings
- 反選 Index source files not included in the build
- 反選 Allow heuristic resolution of includes
- 點擊 Apply 提交修改
-
C/C++ Paths and Symbols. 這將幫助 Eclipse
為 Chrome構建 symbol。- 如果使用gyp構建系統的話,則在命令行中運行GYP_GENERATORS=eclipse build/gyp_chromium;如果使用 gn 構建系統的話,則在命令行中運行 gn gen out/Default/ --ide=eclipse,然后執行命令 tools/android/eclipse/generate_cdt_clang_settings.py out/Default/eclipse-cdt-settings.xml。
- 這將生成 <project root>/out/Release/eclipse-cdt-settings.xml 或 <project root>/out/Default/eclipse-cdt-settings.xml 文件,后面會用到。
- 在左邊的配置樹中選擇 C/C++ General > Paths and Symbols
- 點擊 Restore Defaults 清楚所有舊設置。
- 點擊 Import Settings... 將顯示導入對話框。T
- 點擊 Browse... 將顯示 文件瀏覽器。
- 選擇 <project root>/out/Default/eclipse-cdt-settings.xml。
- 點擊 Finish 按鈕。整個首選項對話框應該消失。
- 在工程上右鍵點擊鼠標,并選擇Index > Rebuild
-
Java
- 創建一個指向 <project root>/tools/android/eclipse/.classpath 的鏈接 <project root>/.classpath:ln -s tools/android/eclipse/.classpath .classpath
-
以如下方式編輯 <project root>/.project ,使工程成為一個Java工程:
- 在 <buildSpec> 中添加如下幾行:<buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments></arguments> </buildCommand>
- 在 <natures> 中添加如下幾行:<nature>org.eclipse.jdt.core.javanature</nature>
參考文檔:
Eclipse Configuration for Android
總結
以上是生活随笔為你收集整理的Chromium Android开发的Eclipse配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用LeakTracer检测androi
- 下一篇: android sina oauth2.