http://geekycoder.wordpress.com/2009/07/03/how-to-download-latest-zip-android-source-code-and-using-it-in-intellij/



That’s definitely true for most developers using Windows as the main development platform and will want to get the latest Android Source code without installing any prerequisite software (Cygwin, repo, git etc) to obtain the latest source code, and hence the fastest way to do so is to obtain the zip Android Source code uploaded by some kind souls. However, it is always best not to depend on someone else in the long run and therefore it will be beneficial to learn how to obtain the latest source code. Although it is unnecessary to periodically getting the latest entire source code, it is good to know that one can easily obtain the latest source code just as easy as saving a file (albeit with much patience) . In addition, the source code may even more valuable if it can be easily accessible in the IDE. So the objectives for this post is

This post will split into two main sections:Downloading the SourceCodeandConfiguring the Source Code for use in Intellij.


« Tribute to Michael Jackson with “I’ll bethere”Review<Song>: A Whiter Shade ofPale»

Android: How to download the latest zip Android Source Code easily and using it inIntellij

This is a follow-up to my post:Android: Zip download of Cupcake Android v1.5 source code

There is a popular quote which says

Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.

That’s definitely true for most developers using Windows as the main development platform and will want to get the latest Android Source code without installing any prerequisite software (Cygwin, repo, git etc) to obtain the latest source code, and hence the fastest way to do so is to obtain the zip Android Source code uploaded by some kind souls. However, it is always best not to depend on someone else in the long run and therefore it will be beneficial to learn how to obtain the latest source code. Although it is unnecessary to periodically getting the latest entire source code, it is good to know that one can easily obtain the latest source code just as easy as saving a file (albeit with much patience) . In addition, the source code may even more valuable if it can be easily accessible in the IDE. So the objectives for this post is

This post will split into two main sections:Downloading the SourceCodeandConfiguring the Source Code for use in Intellij.

Downloading the Source Code

In fact, this post takes the inspiration and information from the post“How to explore android source code”by Satya Komatineni, author of the excellent book,Pro Android. Pro Android is a very informative book of its kind to discuss Android programming in depth and really deserve the suffix “Pro”. The same information presenting in his post is included in the book (exclude the part on Eclipse) under the topicTaking Advantage of Android Source Code.

I consider the post by Satya Komatineni as one of the best post for Android development because it discuss on downloading/exploring on the source code of Android and configuring it for use in Eclipse.

Isn’t anyone happy that he can just download the latest source code by just entering the URL in the browser or clicking on the following link ?

File: base-HEAD.tar.gz (30mb)

http://git.source.android.com/?p=platform/frameworks/base.git;a=snapshot;h=HEAD;sf=tgz

How cool is that ? Perhaps it seems like old news for Android Veteran, but for many newbies that just step into the world of Android, it seems like a great news. In fact, this URL is mentioned in many blog comment and discussion forum but not frequently found in posts (Hence it is one reason for this post). But be warned that the 30mb download does require some patience as it does not support download accelerator and the speed is average 15kbps.

Content of the file

The right side contains the package under android directory.

Or another alternative ?

But for those who are impatient and rather just need the source code equivalent of android.jar, you just download the following 2mb source code jar file using Download Accelerator. Essentially the source jar file contains those source from the directory <base\core\java & base\graphics>. However, do take note that the android.jar file bundled with the Android SDK contains only subset of class files. There are some classes stripped off from android.jar.

File: android15_src.zip (3mb)

FAQ of the Source Code

Is the downloaded source code (base-HEAD.tar.gzfile) compliable?

NO. The source only contains the subset of the full source that required for successful compilation. Basically it contains the source of those class that is accessible from your IDE (through auto-completion etc) usingandroid.jarthat come with the SDK. For example, sources such as those from package android.telephony and third-party library are missing (Yes, clearly missing from the download, not that they locate in other directory).

Attempt to compile the source in Intellij results in the following errors

Will IDE display the source code that is included in source code directory/Jar file (android15_src.zip file) but which its class equivalent is not in android.jar ?

NO. It makes sense that IDE only recognizes the classes in a library (after all it is the binary library that get run, not the source code) and then from the class, attempt to find its source equivalent from the classpath, and not vice versa. This unfortunately means that the IDE is unable to find those source of class that is been intentionally stripped off in android.jar (properly to avoid been .

Configuring Android Source Code for use in Intellij

For Android development, you have to use the latestIntellij 9 M1 (beta) release (download here) . The latest working Android plug-in is incompatible with Intellij 8.XXX. It appears that Android support is only available in Intellij 9 ultimately (?). For those who yet to try on Intellij, please do so otherwise you might just miss out the one of the best things in the software development world.

Remember too to update to latest Android plugin (v0.9.3) as the one in M1 is the old version. The new version is much more robust and work flawlessly.

Intellij makes it so easy to add source code directory or zip/jar files for Java library. The following video shows how easy to add Android source code support in Intellij.

Use the android.jar from either android-1.1 or android-1.5 directory.

The most important step to take note is thatandroid.jar must be re-addedas a library even though the project already include the Android module, otherwise Intellij will not be able to use the source code.

The following video shows

1) Creating a new Android project (It is here that you specify the Android module)

2) Creating library and addingandroid15_src.zipfor use

3) Navigate the Android source by cntrl+click on Android class name.

Note that it is useless to specify the Sources under [Configure Module Library] screen because the Sources will never be saved no matter how (Is this a bug ?). It is because of this reason that the aforementioned step is required.

That’s it. Enjoy your Android Application development as much as I do !


更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android studio常用控件
  2. Android入门一:Android(安卓)开发环境安装
  3. Android(安卓)requires compiler complia
  4. 使用Javascript判断浏览器终端设备(PC、I
  5. Android概述
  6. android SDK系统图片资源的路径。
  7. 补间动画--透明渐变XML
  8. Android启动画面实现
  9. 【读书笔记】【Android(安卓)开发艺术探
  10. 修改Android(安卓)EditText光标颜色