AOSP eclipse

引自:http://apienthusiast.blogspot.com/2014/06/using-eclipse-to-browse-and-edit-aosp.html



Using Eclipse to browse and edit Android platform source code

Android platform consists of millions of lines of C, C++ and Java code. I am part of a team building an embedded device that uses Android as OS. One of the challenges we have often faced as developers is how to navigate Android platform code (aka AOSP) easily. 

Most IDEs like Eclipse, IntelliJ provide shortcuts to do this if the source code is managed through a project. Using Eclipse page on AOSP site describes importing the source code into Eclipse. That doesn't work as expected. Following those instructions broke AOSP build because of artifacts left behind by the Eclipse project. This post describes a way to accomplish this without breaking AOSP build.

Lets assume the AOSP sources are located at /home/videoguy/platform/mars folder. This is the top level folder under which you should see frameworks, build, kernel etc sub directories. This folder is referred as <aosproot> in the sections below. To keep this folder clean from IDE artifacts, we need to create a shadow folder. Lets assume the shadow folder is located at  /home/videoguy/platform/ide/mars . This folder is referred as<shadowroot> below.
  1. Open a terminal window and change directory to <aosproot>
    Build the AOSP platform the way you normally do.  You should see <aosproot>/outwith build artifacts after this.
     If you haven't created <shadowroot> yet, please create it before continuing. The directory structure should look like below.
  2. Change directory to <shadowroot>. Invoke lndir command like below at command prompt. 

    $lndir ../../mars
    This will make the shadow directory mimic the structure of <aosproot> with symlinks pointing to files under <aosproot>. If you make changes to the files from Eclipse, the files under <aosproot> get changed and vice versa.
  3. Copy development/ide/eclipse/.classpath to <shadowroot>. The following command will do if invoked from <shadowroot> folder.

    $cp development/ide/eclipse/.classpath .
  4. Launch Eclipse. This procedure was tested using Kepler version of Eclipse running on UBuntu. Make sure you have 512MB of heap space set aside. On my box, eclipse is launched like below.
    $eclipse -vmargs -Xmx512M -Xms256M -XX:MaxPermSize=256M

  5. Create a new Java Project. For this, Choose File->New->Java Project or right click in "Package Explorer" space and select "New->Java Project" menu item. 
    For "Project Name", enter "Android Platform".
    Uncheck "Use default location" and browse and select <shadowroot> directory.

    The new project dialog should look like below.


  6. Press "Next" button and wait. This step takes around 30 seconds.
  7. Press "Finish" and wait. This takes around 10-20 seconds. You might see "Eclipse running out of memory" error or "GC limit reached" error. If eclipse prompts you to close workbench, please do so. You can ignore these errors.
  8. Close Eclipse and Relaunch. You should see "Android Platform" project like below when expanded.



This is a great way to edit platform Java code using IDE with source completion and other goodies.
Please keep in mind that this project is meant for browsing, editing and debugging Framework java code. It is not meant for building AOSP from eclipse. Please use a terminal window to make builds manually. 

In a future posting, I will show you how to debug framework service like window manager using this project.


  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值