android源代码结构

查了许久,并没有发现介绍 android 源码结构的文档(google并没出这样的文档),Google可以搜索到一些信息:

下面是从国外网站某bbs上摘抄的一段话,对 android源码目录结构进行了一个大概的介绍

Here is short version of what you will find when you download the Android source. I will leave out some minor directories and dig deeper into a couple of the important ones. Basically what you will get (based on the current Ice Cream Sandwich release), in alphabetical order:

  • Bionic - the C-runtime for Android. Note that Android is not using glibc like most Linux distributions. Instead the c-library is called bionic and is based mostly on BSD-derived sources. In this folder you will find the source for the c-library, math and other core runtime libraries.
  • Bootable - boot and startup related code. Some of it is legacy, the fastboot protocol info could be interesting since it is implemented by boot loaders in a number of devices such as the Nexus ones.
  • Build - the build system implementation including all the core make file templates. An important file here is the envsetup.sh script that will help you a lot when working with the platform source. Running this script in a shell will enable commands to setup environment variables, build specific modules and grep in source code files.
  • Cts - the compatability tests. The test suite to ensure that a build complies with the Android specification.
  • Dalvik - the source code for the implementation of the Dalvik Virtual Machine
  • Development - projects related to development such as the source code for the sdk and ndk tools. Normally not a folder you touch when working with the platform for a target.
  • Device - product specific code for different devices. This is the place to find hardware modules for the different Nexus devices, build configurations and more.
  • External - contains source code for all external open source projects such as SQLite, Freetype and webkit.
  • Frameworks - this folder is essential to Android since it contains the sources for the framework. Here you will find the implementation of key services such as the System Server with the Package- and Activity managers. A lot of the mapping between the java application APIs and the native libraries is also done here.
  • Hardware - hardware related source code such as the Android hardware abstraction layer specification and implementation. This folder also contains the reference radio interface layer (to communicate with the modem side) implementation.
  • (Kernel) - not part of the default source download but you can get access to this code either by downloading it manually or by adding the repository to the repo tool. Contains the sources for the Android version of the Linux kernel.
  • Out - the build output will be placed here after you run make. The folder structure is out/target/product/. In the default build for the emulator the output will be placed in out/target/product/generic. This is where you will find the images used by the emulator to start (or to be downloaded and flashed to a device if you are building for a hardware target).
  • Packages - contains the source code for the default applications such as contacts, calendar, browser.
  • Prebuilt - contains files that are distributed in binary form for convenience. Examples include the cross compilations toolchains for different development machines.
  • System - source code files for the core Android system. That is the minimal Linux system that is started before the Dalvik VM and any java based services are enabled. This includes the source code for the init process and the default init.rc script that provide the dynamic configuration of the platform

Beyond the above you also have the hidden .repo directory that contains the source for the repo utility. It also holds the manifest specifying what git repositories you want to track for this Android source project. If you have your own additions you could automatically track them by adding a local manifest here.

For modifications of the platform framework there are some instructions available in the device/sample folder of the source code tree. That will show you how to add APIs to Android without having to modify the core framework.


上面标红的几个目录是最容易理解其作用的,对于 Android 应用程序开发者最需要关注的就是 FrameworksPackages 这两个目录了,其它的目录暂时略去吧.


比如 Developer Guide 中提到学习 style和theme时可以使用 系统 built-in 的 style和theme, 但有些系统自定义的 style 只根据其名子并不能完全知道它的意思,这时可以通过查看源代码中的  styles.xml和themes.xml这两个文件,从源代码中就能清楚了解系统是如何定义的。

它们在:frameworks/base/core/res/res/values/   目录下



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值