Ubuntu9.10下获取Android源码

首先根据http://source.android.com/download网页上的描述可知,源码大概有2.1GB,需要6GB空间才能编译,因为我是在虚拟机上装的Ubuntu9.10,所以虚拟机至少要有10GB空间。粗体,下划线部分是我安装中遇到的一些问题,或者重点关注的地方

 

首先需要安装开发环境,需要如下包:
  • Required Packages:
    • Git 1.5.4 or newer and the GNU Privacy Guard. 
  •  
    • JDK 5.0, update 12 or higher.  Java 6 is not supported, because of incompatibilities with @Override. //只能用JDK5,JDK6不能兼容@Override
  •  
    • flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip, curl.  
$ sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
  • You might also want Valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc.//这个是帮你寻找内存漏洞,堆溢出,数组越界溢出的工具 
$ sudo apt-get install valgrind

 

 

Ubuntu9.10的安装源已经没有JDK5了,所以需要用到9.04的安装源

修改/etc/apt/sources.list把9.04的源:
deb http://run.hit.edu.cn/ubuntu/ jaunty main restricted universe multiverse
deb-src http://run.hit.edu.cn/ubuntu/ jaunty main restricted universe multiverse
deb http://run.hit.edu.cn/ubuntu/ jaunty-updates main restricted universe multiverse
deb-src http://run.hit.edu.cn/ubuntu/ jaunty-updates main restricted universe multiverse
deb http://run.hit.edu.cn/ubuntu/ jaunty-backports main restricted universe multiverse
deb-src http://run.hit.edu.cn/ubuntu/ jaunty-backports main restricted universe multiverse
deb http://run.hit.edu.cn/ubuntu/ jaunty-security main restricted universe multiverse
deb-src http://run.hit.edu.cn/ubuntu/ jaunty-security main restricted universe multiverse

update之后,用sudo apt-get install sun-java5-jdk 即可像以往一样安装java 1.5

安装后的基本设置
sudo update-alternatives --config java
sudo update-java-alternatives -s java-1.5.0-sun
这时候再用java -version就能看到java 1.5已经正常工作了

 

 

接下来就是安装repo

To install, initialize, and configure Repo, follow these steps:
  1. Make sure you have a ~/bin directory in your home directory, and check to be sure that this bin directory is in your path:
      $ cd ~
      $ mkdir bin
      $ echo $PATH
  2. Download the repo script and make sure it is executable:
    $ curl http://android.git.kernel.org/repo >~/bin/repo
    $ chmod a+x ~/bin/repo

初始化repo

  1. Create an empty directory to hold your working files: 
    $ mkdir mydroid
    $ cd mydroid
  2. Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest:
    $ repo init -u git://android.git.kernel.org/platform/manifest.git
    • If you would like to check out a branch other than "master", specify it with -b, like:
      $ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
  3. When prompted, configure Repo with your real name and email address. If you plan to submit code, use an email address that is associated with a Google account
A successful initialization will end with a message such as
   repo initialized in /mydroid

Your client directory should now contain a .repo directory where files such as the manifest will be kept. 

 

 

 

获取代码

To pull down files to your working directory from the repositories as specified in the default manifest, run 

   $ repo sync  

For more about repo sync and other Repo commands, see Using Repo and Git.

The Android source files will be located in your working directory under their project names. 

 

验证代码

Load the following public key into your GnuPG key database.  The key is used to sign annotated tags that represent releases.

   $ gpg --import

then paste the key(s) below, and press Control-D to end the input and process the keys.  After importing the keys, you can verify any tag with

   $ git tag -v tagname

key 9AB10E78: "The Android Open Source Project <initial-contribution@android.com>"

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
8tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD
u4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0Z
wNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq
/HMdOY7LJlH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jEGqmUtkBszwo
G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ
hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l
EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
=Wi5D
-----END PGP PUBLIC KEY BLOCK-----
 
编译代码
To build the files, run make from within your working directory:
    $ cd ~/mydroid  
    $ make

If your build fails, complaining about a missing "run-java-tool", try setting the ANDROID_JAVA_HOME env var to $JAVA_HOME before making.  E.g.,

    $ export ANDROID_JAVA_HOME=$JAVA_HOME

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值