Android2.3.6源码下载编译

1.安装ubuntu10.04版本64位

2.安装jdk
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk

3.安装需要的包
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
  x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
  libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
  libxml2-utils xsltproc

4.USB设备配置
在相应目录创建文件
/etc/udev/rules.d/51-android.rules
拷贝以下信息到此文件,然后保存(username  must be replaced by the actual username of the user who is authorized to access the phones over USB.)
# adb protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER=""
# fastboot protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER=""
# adb protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER=""
# fastboot protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER=""
# adb protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER=""
# fastboot protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER=""
# adb protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER=""
# fastboot protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER=""
# adb protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER=""
# fastboot protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER=""
# usbboot protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", MODE="0600", OWNER=""
# usbboot protocol on panda (PandaBoard ES)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0600", OWNER=""
# adb protocol on grouper (Nexus 7)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0600", OWNER=""
# fastboot protocol on grouper (Nexus 7)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40", MODE="0600", OWNER=""

5.源码下载
1).Installing Repo
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
2).Initializing a Repo client
进入源码存放目录执行
repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.6_r1
3).Getting the files
repo sync
6.源码编译
1)Initialize
进入源码根目录
$ . build/envsetup.sh

2).Choose a Target

$ lunch full-eng


3).Build the Code
$make

可能遇到一些编译出错问题,具体问题具体分析解决,

eg:

1)host c++: libhost <= build/libs/host/pseudolocalize.cpp/bin/bash: g++: 未找到命令
make: ***[out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/pseudolocalize.o] 错误 127
 解决方法:$ sudo apt-get install build-essential


2)
host c: adb<= system/core/adb/fdevent.c
host Executable:adb (out/host/linux-86/obj/EXECUTABLES/adb_intermediates/adb)/user/bin/ld: cannot find –lncurses
collect2: ld 返回 1
make: ***[out/host/linux-86/obj/EXECUTABLES/adb_intermediates/adb] 错误 1
 解决方法:$sudo apt-get install libncurses5-dev
 
3)
make: ***[out/target/product/sam9g45/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h] 错误 25
 解决方法:$sudo apt-get install gpert
 
 
4)
make: ***[out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/android/skin/window.o] Error 1
 解决方法:$ sudo apt-get install libx11-dev
成功之后在out目录有几个镜像文件


7.开启模拟器
make成功后运行模拟器,配置环境变量,使用所编译的镜像文件
export ANDROID_PRODUCT_OUT=/media/work/AndroidSrc2.3/out/target/product/generic
export PATH=$PATH:/media/work/AndroidSrc2.3/out/host/linux-x86/bin
执行emulator

此过程中遇到问题:
1.编译成功之后,运行模拟器,一直停留在开机logo"Android",这个问题好伤脑袋,查看log信息:
E/webcoreglue(  208): WebViewCore registration failed!
W/dalvikvm(  208): JNI_OnLoad returned bad version (-1) in /system/lib/libwebcore.so 0x0
W/dalvikvm(  208): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Landroid/webkit/WebViewCore;
E/Zygote  (  208): Error preloading android.webkit.WebViewCore.
E/Zygote  (  208): java.lang.ExceptionInInitializerError
E/Zygote  (  208): at java.lang.Class.classForName(Native Method)
E/Zygote  (  208): at java.lang.Class.forName(Class.java:234)
E/Zygote  (  208): at java.lang.Class.forName(Class.java:181)
E/Zygote  (  208): at com.android.internal.os.ZygoteInit.preloadClasses(ZygoteInit.java:297)
E/Zygote  (  208): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:564)
E/Zygote  (  208): at dalvik.system.NativeStart.main(Native Method)
E/Zygote  (  208): Caused by: java.lang.UnsatisfiedLinkError: unknown failure
E/Zygote  (  208): at java.lang.Runtime.loadLibrary(Runtime.java:455)
E/Zygote  (  208): at java.lang.System.loadLibrary(System.java:554)
E/Zygote  (  208): at android.webkit.WebViewCore.(WebViewCore.java:61)
E/Zygote  (  208): ... 6 more
E/Zygote  (  208): setreuid() failed. errno: 17

解决办法:WebViewCore.java不加载libwebcore.so(先把模拟器弄出来在解决这个问题),重新make


8.打开ddms调试

可能会找不到swt.jar
配置环境变量
#export ANDROID_SWT=/media/work/AndroidSrc2.3/out/host/linux-x86/framework
执行ddms


模拟器:


 



你可能感兴趣的:(android)