刚刚接触android系统,虽然也下载了源代码,编译,运行都通过了,自己却蒙上了不少雾水。
编译运行成功,查看android版本,发现是AOSP。才记起,原来自己下完了源码却不清楚他的版本。
我使用repo下载时,默认的branch是master, 也就是说使用的命令是
$ repo init -u git://android.git.kernel.org/platform/manifest.git
而没有 -b < branch> 选项,因此默认是最新的版本
那么如何才能下载到指定版本呢,目前我能找到的方法就是通过设定 “ -b ” 参数来决定,具体branch的名字和android不同版本的“昵称”有关。详情如下
Android 2.3 corresponded to the "Gingerbread" milestone branch, and has an API level of 9. 对应的命令就是
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b gingerbread
Android 2.2 corresponded to the "FroYo" milestone branch, and has an API level of 8. 对应的命令就是
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b FroYo
Android 2.1 corresponded to the "Eclair" milestone branch, and has an API level of 7. 对应的命令就是
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair
Android 1.6 corresponded to the "Donut" milestone branch, and has an API level of 4. 对应的命令就是
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b donut
Android 1.5 corresponded to the "Cupcake" milestone branch, and has an API level of 3. 对应的命令就是
$ repo init -u git://android.git.kernel.org/platform/manifest.git cupcake
接着再运行 $ repo sync 就可以下载对应的版本的源代码了
应为是下载的源码自己编译的,因此android version 是AOSP,
同样如果用源码编译出kernel的zImage,你会发现kernel version好玩的信息的
下面一点算是对AOSP的解惑吧, 转自http://www.qkevin.com/archives/257
Author: Q-Kevin @ http://www.qkevin.com
从Google的server上下载一份Android的source code,老费劲了,或许是自己的网速是龟速吧,辛辛苦苦的build完了之后,run了一下命令android,create了一个AVD,一看,Target Name是"Android AOSP(Preview)",Platform也是AOSP,Google了一下才知道,原来AOSP是Android Open Source Project的首字母缩写,这和直接下载的Android SDK的版本号对不上呀。而且,使用SDK创建出来的AVD,用源代码build出来的emulator也不能用,木有办法,只好再create一个AVD,这玩意儿是挺烦了,那么下载下来android的源代码到底对应的SDK是哪个版本呢?
据某些网络上的大虾说,源代码的版本和SDK的版本不是一一对应的,这个偶没有去琢磨,也无从知晓。自己还是费了老大的功夫从source code中找到了这个版本号到底是写在哪里的。
在 $ANDROIDTOP/build/core目录下面有一个文件,version_defaults.mk,这个文件定义了这个版本号,
打开这个文件,可以找到如下的信息,它就定义了Platform Version:
ifeq "" "$(PLATFORM_VERSION)"
# This is the canonical definition of the platform version,
# which is the version that we reveal to the end user.
# Update this value when the platform version changes (rather
# than overriding it somewhere else). Can be an arbitrary string.
PLATFORM_VERSION := AOSP
endif
还有下面的信息,定义了开发过程中的 code-name,如果对应的是最终的发行版,则是REL
ifeq "" "$(PLATFORM_VERSION_CODENAME)"
# This is the current development code-name, if the build is not a final
# release build. If this is a final release build, it is simply "REL".
PLATFORM_VERSION_CODENAME := AOSP
endif
下面的信息就定义了和SDK相对应的版本号。每一个SDK都有一个API Level,这个版本号就和SDK中的API Level是保持一致的。
ifeq "" "$(PLATFORM_SDK_VERSION)"
# This is the canonical definition of the SDK version, which defines
# the set of APIs and functionality available in the platform. It
# is a single integer that increases monotonically as updates to
# the SDK are released. It should only be incremented when the APIs for
# the new release are frozen (so that developers don't write apps against
# intermediate builds). During development, this number remains at the
# SDK version the branch is based on and PLATFORM_VERSION_CODENAME holds
# the code-name of the new development work.
PLATFORM_SDK_VERSION := 9
endif
这些发现到底对不对?我也不知道,或许这个自己每次都是下载最新的版本有关系吧,所以download下来的版本总是AOSP,如果要下载的是某一个特定的版本,会怎么样呢?try一下就知道了。