Android 4.2编译过程笔记

Android 4.2编译环境的安装

1.安装先到官方网站下载一个jdk6的安装包

http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u45-oth-JPR

我的系统为Ubuntu12.0464位,对应自己系统下载好了

2.配置jdk

编辑~/.bashrc 添加

export PATH=~/bin:$PATH

export JAVA_HOME=~/bin/jdk1.6.0_45/

export JRE_HOME=$JAVA_HOME/jre

export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

运行source ~/.bashrc 使之生效

3.按照官网指导

Installing required packages (Ubuntu 12.04)

--------------------------------------------------------------------------------

Building on Ubuntu 12.04 is currently only experimentally supported and is not guaranteed to work on branches other than master.

$ sudo apt-get install git gnupg flex bison gperf build-essential \

zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \

libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \

libgl1-mesa-dev g++-multilib mingw32 tofrodos \

python-markdown libxml2-utils xsltproc zlib1g-dev:i386

$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

4.编译代码

进入源码根目录

编译初始化:

在终端中执行:

source build/envsetup.sh

执行后输出:

source build/envsetup.sh

including device/asus/grouper/vendorsetup.sh

including device/asus/tilapia/vendorsetup.sh

including device/generic/armv7-a-neon/vendorsetup.sh

including device/generic/armv7-a/vendorsetup.sh

including device/generic/mips/vendorsetup.sh

including device/generic/x86/vendorsetup.sh

including device/samsung/maguro/vendorsetup.sh

including device/samsung/manta/vendorsetup.sh

including device/samsung/toroplus/vendorsetup.sh

including device/samsung/toro/vendorsetup.sh

including device/ti/panda/vendorsetup.sh

including sdk/bash_completion/adb.bash

选择编译目标:

lunch full-eng

执行后会又以下信息提示:

============================================

PLATFORM_VERSION_CODENAME=REL

PLATFORM_VERSION=4.2

TARGET_PRODUCT=full

TARGET_BUILD_VARIANT=eng

TARGET_BUILD_TYPE=release

TARGET_BUILD_APPS=

TARGET_ARCH=arm

TARGET_ARCH_VARIANT=armv7-a

HOST_ARCH=x86

HOST_OS=linux

HOST_OS_EXTRA=Linux-2.6.32-45-generic-x86_64-with-Ubuntu-10.04-lucid

HOST_BUILD_TYPE=release

BUILD_ID=JOP40C

OUT_DIR=out

============================================

编译代码:

在终端中执行:make -j4

-j4:表示用四个线程来编译:

我用虚拟机,配置为4g,交换空间为2g,编译了大约6个小时。

运行模拟器

在终端中执行:emulator

Android 4.2编译过程笔记

在  ~/.bashrc

添加环境变量:

export ANDROID_PRODUCT_OUT=~/code/android-4.2/out/target/product/generic

export ANDROID_SWT=~/code/android-4.2/out/host/linux-x86/framework/

备注:

重启系统后:

执行emulator,出现如下错误:

emulator: ERROR: You did not specify a virtual device name, and the system

directory could not be found.

If you are an Android SDK user, please use '@<name>' or '-avd <name>'

to start a given virtual device (see -help-avd for details).

Otherwise, follow the instructions in -help-disk-images to start the emulator

解决:

source build/envsetup.sh

lunch sdk-eng

然后再执行

emulator

可以启动模拟器

相关推荐