1. 环境

Ubuntu 10.04 32-bit

sudo apt-get install git-core

sudo apt-get install curl

sudo apt-get install zlib -dev 变为 sudo apt-get install zlib1g -dev

sudo apt-get install bison

sudo apt-get install flex

sudo apt-get install libncurses-dev (libncurses5-dev)

sudo apt-get install g++

sudo apt-get install libx11-dev

sudo apt-get install gperf

安装Java6

关于Java版本:Java6能够编译代码,但不能生成文档,最好准备两套Java环境

Ubuntu 10.04 64-bit

sudo apt-get install libc6-dev-i386

sudo apt-get install lib32ncurses5-dev

sudo apt-get install libx11-dev

sudo apt-get install g++-multilib

sudo apt-get install lib32z1-dev

64-bit Java6

2. 下载Android SDK

curl http://android.git.kernel.org/repo > ~/bin/repo

chmod a+x ~/bin/repo

如果是想把Android当前主线上最新版本的所有的sourcecode拿下来,www.linuxidc.com我们需要repo的帮助。
先建立一个目录,比如~/android,进去以后用repo init命令即可。
repo init -u git://android.git.kernel.org/platform/manifest.git

获取eclair代码:

repo init -u http://android.git.kernel.org/platform/manifest.git -b eclair

从Android 2.2开始,编译SDK需要64位系统,32位的,只好先编译Eclair了.

repo init -u http://android.git.kernel.org/platform/manifest.git -b eclair

repo sync

3. 编译

make

cd eclair

. ./build/envsetup.sh

make sdk

在模拟器上运行编译好的android
编译好android之后,emulator在~/android/out/host/linux-x86/bin 下,ramdisk.img,system.img和userdata.img则在~/android/out/target/product /generic下
$ cd ~/android/out/host/linux-x86/bin
增加环境变量
$ emacs ~/.bashrc
在.bashrc中新增环境变量,www.linuxidc.com如下
#java 程序开发/运行的一些环境变量
export ANDROID_PRODUCT_OUT=~/android/out/target/product/generic
ANDROID_PRODUCT_OUT_BIN=~/android/out/host/linux-x86/bin
export PATH=${PATH}:${ANDROID_PRODUCT_OUT_BIN}:${ANDROID_PRODUCT_OUT};

最后,同步这些变化:
$ source ~/.bashrc
$ cd ~/android/out/target/product/generic
$ emulator -system system.img -data userdata.img -ramdisk ramdisk.img
最后进入android桌面,就说明成功了。

4. 编译模块

android中的一个应用程序可以单独编译,编译后要重新生成system.img
在源码目录下执行
$ . build/envsetup.sh (.后面有空格)
就多出一些命令:
- croot:   Changes directory to the top of the tree.
- m:       Makes from the top of the tree.
- mm:      Builds all of the modules in the current directory.
- mmm:     Builds all of the modules in the supplied directories.
- cgrep:   Greps on all local C/C++ files.
- jgrep:   Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
- godir:   Go to the directory containing a file.
可以加—help查看用法
我们可以使用mmm来编译指定目录的模块,如编译联系人:
$ mmm packages/apps/Contacts/
编完之后生成两个文件:
out/target/product/generic/data/app/ContactsTests.apk
out/target/product/generic/system/app/

5. 直接执行make是不包括make sdk的。make sdk用来生成SDK,这样,我们就可以用与源码同步的SDK来开发android

更多相关文章

  1. android 生成密钥 签名
  2. android-环境
  3. android 系统编译要求,官方资料
  4. Android中编译工具链的改动----LLVM份量的增加
  5. android stdio Error Could not find com.android.tools common
  6. 尝试 Android(安卓)Bilibili/ijkplayer
  7. Android编译系统详解(三)
  8. Android编译系统详解(二)
  9. Android多媒体开发(3)————使用Android(安卓)NKD编译havlenapet

随机推荐

  1. Android Apache Commons工具库依赖列表
  2. android google map v2的小例子 美洲地图
  3. 一个网友写的android开发随笔,不错,可以参
  4. Android(安卓)客户端与PC服务端socket通
  5. 阻止一进入页面就弹输入法对话框的方法
  6. android 对话提示框大全
  7. 改变button按钮的形状
  8. android GridView选择照片的完整实现
  9. Android Jetpack ViewModel管理数据
  10. 关于正确使用Android(安卓)AsyncTask学习