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

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 Source Code andConfiguring the Source Code for use in Intellij.


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

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

imageGive 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 Source Code andConfiguring the Source Code for use in Intellij.

Downloading the Source Code

imageIn 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 topic Taking 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 ?

image 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.

 image

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.

image File: android15_src.zip (3mb)

 

FAQ of the Source Code

Is the downloaded source code (base-HEAD.tar.gz file) 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) using android.jar that 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

image

 

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

imageFor 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. 

 image

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

 

The most important step to take note is that android.jar must be re-added as 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 adding android15_src.zip for 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.

image

 

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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 解决 IntelliJ IDEA 的无效源分发问题的方法如下: 1. 确保您正在使用正确的下载链接,并确保您已经正确下载了 IntelliJ IDEA 安装包。 2. 如果您使用的是 .zip 文件,请确保您已经正确解压缩了该文件。 3. 请确保您的系统上没有安装任何类似于杀毒软件、防火墙等影响安装的程序。 4. 请确保您的系统上的 Java 环境是最新版本。 如果以上方法均无效,您可以尝试重新下载安装包,或者联系 IntelliJ IDEA 的客服人员寻求帮助。 ### 回答2: 解决IntelliJ IDEA的无效源分发问题可以按以下步骤进行: 1. 检查源文件是否存在。首先,确保你的项目包含正确的源文件。请检查项目的源文件目录结构,确保源文件正确地放置在对应的包中。 2. 检查编译选项。确保项目的编译选项正确配置。在IDEA的设置中,检查编译设置并确保指定了正确的源目录和输出目录。如果设置错误,可能会导致无效的源分发。 3. 清理和重新构建项目。尝试使用IDEA的清理和重新构建项目功能。这将清除旧的构建文件和生成文件,并重新构建项目。这有助于解决一些构建相关的问题。 4. 更新或重新安装IDEA。如果以上步骤都无效,可能需要考虑更新或重新安装IntelliJ IDEA。升级到最新版本可能会修复一些已知的问题。重新安装可以确保IDEA的完整性,并清除可能存在的错误配置。 5. 检查依赖项和库。无效的源分发也可能由依赖项或库的问题引起。请确保您的项目中使用的依赖项和库已正确安装和配置。检查依赖项的版本和配置信息是否与您的项目兼容。 如果上述步骤仍无法解决问题,您可能需要进一步调查错误日志和其他提示,以找出导致无效源分发的具体原因。您还可以考虑与IntelliJ IDEA的社区或支持团队联系,寻求更专业的帮助和指导。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值