2013-05-16 246 views
10

有沒有人試圖使用IntelliJ IDEA與AOSP一起工作?我在Android源文件中看到了一個特定的文件夾(development/ide/intellij),但在Android開發中我找不到任何有關如何使用它的信息(對於Eclipse,信息可以在這裏找到:http://source.android.com/source/using-eclipse.html)任何人都可以提供類似的說明在IDEA中開發Android?AOSP和IntelliJ IDEA

回答

7

從AOSP根文件夾,

1)首先建立你的目標。這將生成任何需要在aosp構建期間生成的java文件。 2)使用lndir創建aosp dir的陰影目錄。 假設你的目標是〜john/work/aosp/ics。 然後創建〜/ john/work/aosp/icsshadow

Cd轉成icsshadow並調用「lndir ../ics」。這將創建符合ics下的所有符號鏈接。

3)現在,您可以將icsshadow用於IDE所需/生成的所有東西。如果您使用ics文件夾,如果IDE生成任何構建工件,aosp構建有時會失敗。

4)cd到icsshadow目錄。 調用開發/工具/ idegen/idegen.sh

等待,直到完成。 5)如果你想使用IntelliJ,從icsshadow文件夾打開android.ipr。如果你想使用Eclipse,請檢查Using Eclipse to edit/browse AOSP code

+1

的Mac OS X不再有lndir,http://superuser.com/questions/171629/copy-directory-structure-without-copying- files-on-mac-os-x –

8

也是一個很好的閱讀這裏:https://shuhaowu.com/blog/setting_up_intellij_with_aosp_development.html

如果你

找不到idegen.jar。請先運行make。

你需要首先生成它:

source build/envsetup.sh 
cd development/tools/idegen 
mm 
croot 
development/tools/idegen/idegen.sh 

做好準備,AOSP文件IJ索引需要很長時間(1小時以上在我的筆記本上板的SSD),一個理由使用Eclipse,因爲我相信它不需要建立索引,所以加載AOSP代碼要快得多。

值得減少與消除你不感興趣的AOSP部分android.iml文件。你可以通過正則表達式模式將它們添加到development/tools/excluded-paths,看到README文件那裏。

我添加以下行excluded-paths

^cts 
^developers 
^development 
^external 
.*/tests/.* 
^sdk 

所以我android.iml在約1-2分鐘有相當規模適中和負載來代替。

idegen也有intellij-gen.sh它可以爲給定的模塊生成IJ項目。

正如在上面的文章中提到的,你可以調整IJ更快地工作(增加更多的RAM等)。這裏不用我idea64.vmoptions以防萬一:

-server 
-Xms2048m 
-Xmx4096m 
-XX:MaxPermSize=1024M 
-XX:ReservedCodeCacheSize=1024M 
-XX:+UseCodeCacheFlushing 
-XX:+UseCompressedOops 
-XX:+UseConcMarkSweepGC 
-XX:+UseParNewGC 
-XX:ParallelGCThreads=8 
-XX:+AggressiveOpts 
-XX:+CMSClassUnloadingEnabled 
-XX:+CMSIncrementalMode 
-XX:+CMSIncrementalPacing 
-XX:CMSIncrementalDutyCycleMin=0 
-XX:-TraceClassUnloading 
-XX:+TieredCompilation 
-Dsun.io.useCanonCaches=false 
-Djava.net.preferIPv4Stack=true 
-Djsse.enableSNIExtension=false 

可以在Google的想法。vmoptions優化,有一些關於它的帖子(以及我從哪裏拿走了我的IJ配置)

+0

它工作。使用android studio測試它與android-5。 –

0

官方說明可以通過去development/tools/idegen路徑和檢查README文件找到。自己閱讀是個好主意。這是的IntelliJ內容:

如果您使用的IntelliJ ...

如果這是使用IDEGen你第一次......

IDEA needs a lot of memory. Add "-Xms748m -Xmx748m" to your VM options 
    in "IDEA_HOME/bin/idea.vmoptions" on Linux or 
    "IntelliJ IDEA.app/Contents/Info.plist" on OS X. 

    Create a JDK configuration named "1.6 (No Libraries)" by adding a new 
    JDK like you normally would and then removing all of the jar entries 
    under the "Classpath" tab. This will ensure that you only get access to 
    Android's core libraries and not those from your desktop VM. 

從項目的根目錄。 ..

Repeat these steps after each sync... 

    1) make (to produce generated .java source) 
    2) development/tools/idegen/idegen.sh 
    3) Open android.ipr in IntelliJ. If you already have the project open, 
    hit the sync button in IntelliJ, and it will automatically detect the 
    updated configuration. 

    If you get unexpected compilation errors from IntelliJ, try running 
    "Build -> Rebuild Project". Sometimes IntelliJ gets confused after the 
    project changes significantly. 

以下錯誤消息可能會繼instructi時彈出附件。

找不到idegen.jar。請先運行make。

你可以通過閱讀這裏修復錯誤消息:https://www.protechtraining.com/blog/post/860?ncr=1