玩不起真手机,就玩玩模拟器吧
#######################################################
获得android4.0源码
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
$ repo init -u https://android.googlesource.com/platform/manifest
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
$ repo sync
#######################################################
安装必要包
sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip
curl libncurses5-dev zlib1g-dev g++
我用的系统是ubuntu10.04的虚拟机,笔记本内存2G,
虚拟机内存设的是1G,在虚拟机编译速度慢的可想而知,
编译花了好几天的.
######################################################
############解决源代码文件夹太大的问题################
源代码获取后
rm -rf .repo
rm -rf `find . -name .git`
######################################################
############解决java版本报错的问题####################
安装java 1.6
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jdk
设置环境变量
修改~/.bashrc增加下面的内容:
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=/usr/lib/jvm/java-6-sun/bin:$PATH
export CLASSPATH=/usr/lib/jvm/java-6-sun/lib/tools.jar:/usr/lib/jvm/java-6-sun/lib/dt.jar:/usr/lib/jvm/java-6-
sun/lib/rt.jar:/usr/lib/jvm/java-6-sun/lib/
执行命令
source ~/.bashrc
######################################################
编译开始
work@ubuntu:/media/zhaodezhong/study/ics_source$ . build/envsetup.sh
including device/samsung/maguro/vendorsetup.sh
including device/samsung/tuna/vendorsetup.sh
including device/ti/panda/vendorsetup.sh
including sdk/bash_completion/adb.bash
work@ubuntu:/media/zhaodezhong/study/ics_source$ lunch
You're building on Linux
Lunch menu... pick a combo:
1. full-eng
2. full_x86-eng
3. vbox_x86-eng
4. full_maguro-userdebug
5. full_tuna-userdebug
6. full_panda-eng
Which would you like? [full-eng] 1
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.0.1
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_BUILD_TYPE=release
BUILD_ID=ITL41D
============================================
work@ubuntu:/media/zhaodezhong/study/ics_source$ make
###############
错误一:头文件找不到
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_CONNSECMARK.c
target thumb C: libext <= out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_conntrack.c
target thumb C: libext <= out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_cpu.c
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:26:41: error:
linux/netfilter/xt_connmark.h: No such file or directory
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c: In function
'connmark_mt_parse':
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:56: error: dereferencing
pointer to incomplete type
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:57: error: dereferencing
pointer to incomplete type
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:58: error: dereferencing
pointer to incomplete type
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c: In function
'connmark_mt_print':
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:97: error: dereferencing
pointer to incomplete type
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:99: error: dereferencing
pointer to incomplete type
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:99: error: dereferencing
pointer to incomplete type
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c: In function
'connmark_mt_save':
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:118: error: dereferencing
pointer to incomplete type
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:122: error: dereferencing
pointer to incomplete type
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:122: error: dereferencing
pointer to incomplete type
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c: At top level:
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:144: error: invalid
application of 'sizeof' to incomplete type 'struct xt_connmark_mtinfo1'
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:144: error: invalid
application of 'sizeof' to incomplete type 'struct xt_connmark_mtinfo1'
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:144: error: invalid
application of 'sizeof' to incomplete type 'struct xt_connmark_mtinfo1'
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:145: error: invalid
application of 'sizeof' to incomplete type 'struct xt_connmark_mtinfo1'
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:145: error: invalid
application of 'sizeof' to incomplete type 'struct xt_connmark_mtinfo1'
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.c:145: error: invalid
application of 'sizeof' to incomplete type 'struct xt_connmark_mtinfo1'
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.o] Error 1
make: *** Waiting for unfinished jobs....
分析原因:我是在windows下用rar解压tar包的,在解压过程中有文件丢失。偷懒的坏处!
解决办法:到linux/netfilter/下发现确实没有xt_connmark.h文件,重新在linux下解压源码的tar包。
########################
问题二:信号9中断了编译过程
(out/target/product/generic/obj/lib/libstagefright_soft_vorbisdec.so)
target Strip: libstagefright_soft_vpxdec (out/target/product/generic/obj/lib/libstagefright_soft_vpxdec.so)
target Strip: libvideoeditorplayer (out/target/product/generic/obj/lib/libvideoeditorplayer.so)
target SharedLib: libwebcore
(out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/LINKED/libwebcore.so)
compiling all .cfh files into .class files
elapsed seconds: 3930
wrote generated Main_*.java files to out/host/linux-x86/obj/EXECUTABLES/vm-tests_intermediates/main_files
target Executable: SurfaceMediaSource_test
(out/target/product/generic/obj/EXECUTABLES/SurfaceMediaSource_test_intermediates/LINKED/SurfaceMediaSource_test
)
target Executable: SurfaceTexture_test
(out/target/product/generic/obj/EXECUTABLES/SurfaceTexture_test_intermediates/LINKED/SurfaceTexture_test)
target Strip: jpeg_bench (out/target/product/generic/obj/EXECUTABLES/jpeg_bench_intermediates/jpeg_bench)
target SharedLib: libcameraanalyzer
(out/target/product/generic/obj/SHARED_LIBRARIES/libcameraanalyzer_intermediates/LINKED/libcameraanalyzer.so)
target Strip: libplatform_library_jni (out/target/product/generic/obj/lib/libplatform_library_jni.so)
target SharedLib: libsampleplugin
(out/target/product/generic/obj/SHARED_LIBRARIES/libsampleplugin_intermediates/LINKED/libsampleplugin.so)
Install: out/host/linux-x86/lib/libSR_Session.so
Install: out/host/linux-x86/lib/libSR_Recognizer.so
Install: out/host/linux-x86/bin/parseStringTest
Install: out/host/linux-x86/bin/test_g2g
Install: out/host/linux-x86/bin/test_swiarb
collect2: ld terminated with signal 9 [Killed]
make: *** [out/host/linux-x86/obj/EXECUTABLES/dx-tests_intermediates/dx-tests] Killed
make: *** Deleting file `out/host/linux-x86/obj/EXECUTABLES/dx-tests_intermediates/dx-tests'
make: *** Waiting for unfinished jobs....
make: *** [out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/noproguard.classes-with-local.dex]
Killed
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/LINKED/libwebcore.so] Error
1
原因分析:主要是Linux 系统没加swap分区的原因,或是swap分区太小。
解决办法:解决的方法很简单,建个swap文件。
#sudo dd if=/dev/zero of=/opt/other/swapfile bs=1024 count=512K
# sudo mkswap /opt/other/swapfile
# sudo swapon /opt/other/swapfile
# swapon -s
Filename Type Size Used Priority
/dev/sda5 partition 1128440 39588 -1
/opt/other/swapfile file 524280 0 -2
需要注意:在出现这样的情况下,编译命令最好使用单线程的,即make,而不要使用make -j4(可能会出现上面的问题)。
########################
错误三:CTS编译出错
make: Entering directory `/media/zhaodezhong/study/ics_source'
target Symbolic: libcameraanalyzer (out/target/product/generic/symbols/system/lib/libcameraanalyzer.so)
target Strip: libcameraanalyzer (out/target/product/generic/obj/lib/libcameraanalyzer.so)
target Java: CtsVerifier (out/target/common/obj/APPS/CtsVerifier_intermediates/classes)
cts/apps/CtsVerifier/src/com/android/cts/verifier/PassFailButtons.java:191: onCreateDialog
(int,android.os.Bundle) in android.app.Activity cannot implement onCreateDialog(int,android.os.Bundle) in
com.android.cts.verifier.PassFailButtons.PassFailActivity; attempting to assign weaker access privileges; was
public
private static <T extends android.app.Activity & PassFailActivity>
^
1 error
make: *** [out/target/common/obj/APPS/CtsVerifier_intermediates/classes-full-debug.jar] Error 41
make: Leaving directory `/media/zhaodezhong/study/ics_source'
原因分析:原因不详,忘高人指教。。。
解决办法:在网上查了些资料,知道CTS 全称Compatibility Test Suite兼容性测试工具。当电子产品开发出来,并定制了自己
的Android系统后,必须要通过最新的CTS检测,以保证标准的android application能运行在该平台下。通过了CTS验证,需要将
测试报告提交给Google,已取得android market的认证。感觉对android自身运行关系不大,所以干脆不编译这块内容了。
找到cts/下的Android.mk文件,注释掉里面两行代码
#include cts/CtsTestCoverage.mk
#include $(call all-subdir-makefiles)
整个cts/下的代码都不编译了,OK,这个问题解决就编译通过了。
############################
启动模拟器
work@ubuntu:/media/zhaodezhong/study/ics_source$ emulator