编译源码
问题1
In file included from /usr/include/stdlib.h:25:0, from build/tools/acp/acp.c:11:/usr/include/features.h:324:26: fatal error: bits/predefs.h: No such file or directorycompilation terminated.make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o] Error 1
解决方法
sudo apt-get install libc6-dev-i386
问题2
/bin/bash: g++: command not foundmake: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/pseudolocalize.o] Error 127make: *** Waiting for unfinished jobs....:0:0: warning: "_FORTIFY_SOURCE" redefined [enabled by default] :0:0: note: this is the location of the previous definition
解决方法
sudo apt-get install build-essential
问题3
/bin/bash: bison: command not foundmake: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error 127make: *** Waiting for unfinished jobs....
解决方法
sudo apt-get install bison
问题4
/bin/bash: flex: command not foundmake: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127make: *** Waiting for unfinished jobs....
解决方法
sudo apt-get install flex
问题5
/usr/bin/ld: cannot find -lstdc++collect2: ld returned 1 exit statusmake: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp] Error 1make: *** Waiting for unfinished jobs....
解决方法
sudo apt-get install g++-multilib
问题6
/usr/bin/ld: cannot find -lz/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.so when searching for -lstdc++/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a when searching for -lstdc++
解决方法
sudo apt-get install lib32z1-dev
问题7
:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror] :0:0: note: this is the location of the previous definitioncc1plus: all warnings being treated as errorsmake: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1
解决方法
ubuntu 12.04中的gcc版本为4.6版本过高,需要降级为4.4
操作方法
查看gcc版本和g++版本
$ ls -l gcc*lrwxrwxrwx 1 root root 7 Aug 30 19:26 gcc -> gcc-4.6-rwxr-xr-x 1 root root 353216 Apr 16 07:37 gcc-4.6$ ls -l g++*lrwxrwxrwx 1 root root 7 Mar 14 04:05 g++ -> g++-4.6-rwxr-xr-x 1 root root 357312 Apr 16 07:36 g++-4.6
安装gcc和g++4.4版本
sudo apt-get install gcc-4.4 g++-4.4 g++-4.4-multilib
修改gcc链接
$ sudo mv gcc gcc.bak$ sudo ln -s gcc-4.4 gcc$ ls -l gcc*lrwxrwxrwx 1 root root 7 Sep 6 10:43 gcc -> gcc-4.4-rwxr-xr-x 1 root root 259232 Apr 16 14:20 gcc-4.4-rwxr-xr-x 1 root root 353216 Apr 16 07:37 gcc-4.6lrwxrwxrwx 1 root root 7 Aug 30 19:26 gcc.bak -> gcc-4.6
修改g++链接
$ sudo mv g++ g++.bak$ sudo ln -s g++-4.4 g++$ ls -l g++*lrwxrwxrwx 1 root root 7 Sep 6 10:45 g++ -> g++-4.4-rwxr-xr-x 1 root root 263328 Apr 16 14:18 g++-4.4-rwxr-xr-x 1 root root 357312 Apr 16 07:36 g++-4.6lrwxrwxrwx 1 root root 7 Mar 14 04:05 g++.bak -> g++-4.6
查看gcc和g++版本号
gcc-vg++-v
问题8
/usr/bin/ld: cannot find -lncursescollect2: ld returned 1 exit statusmake: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1make: *** Waiting for unfinished jobs....
解决方法
sudo apt-get install lib32ncurses5-dev
问题9
development/tools/emulator/opengl/host/libs/Translator/include/EGL/eglplatform.h:85: fatal error: X11/Xlib.h: No such file or directory
解决方法
sudo apt-get install libx11-dev
问题10
g++: selected multilib '32' not installed make: *** [out/host/linux-x86/obj/EXECUTABLES/etc1tool_intermediates/etc1tool] Error 1 make: *** Waiting for unfinished jobs....
解决方法
sudo apt-get install g++-4.4-multilib
问题11
/usr/bin/ld: cannot find -lX11 collect2: ld returned 1 exit status make: *** [out/host/linux-x86/obj/lib/libOpenglRender.so] Error 1 make: *** Waiting for unfinished jobs....
解决方法(这问题实在不知道怎么解决,最后把网上找到以下包全装了就ok了)
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
问题12
development/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp:22: fatal error: GL/glx.h: No such file or directory compilation terminated. make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libGLcommon_intermediates/GLDispatch.o] Error 1 make: *** Waiting for unfinished jobs....
解决方法
sudo apt-get install libgl1-mesa-dev
问题13
external/iptables/extensions/../include/linux/netfilter/xt_DSCP.h:13:37: error: linux/netfilter/xt_dscp.h: No such file or directory out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_DSCP.c:45: error: 'XT_DSCP_MAX' undeclared here (not in a function) make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_DSCP.o] Error 1 make: *** Waiting for unfinished jobs....
解决方法
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 g++-multilib mingw32 tofrodos gcc-multilib ia32-libs python-markdown libxml2-utils xsltproc zlib1g-dev:i386
问题14
/usr/bin/ld: cannot find -lGL collect2: ld returned 1 exit status /usr/bin/ld: cannot find -lGL collect2: ld returned 1 exit status make: *** [out/host/linux-x86/obj/lib/libGLES_CM_translator.so] Error 1 make: *** Waiting for unfinished jobs.... make: *** [out/host/linux-x86/obj/lib/libEGL_translator.so] Error 1 /usr/bin/ld: cannot find -lGL collect2: ld returned 1 exit status make: *** [out/host/linux-x86/obj/lib/libGLES_V2_translator.so] Error 1
解决方法
$ locate libGL.so/usr/lib/i386-linux-gnu/mesa/libGL.so.1/usr/lib/i386-linux-gnu/mesa/libGL.so.1.2$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1.2 /usr/lib/libGL.so
问题14
external/iptables/extensions/../include/linux/netfilter/xt_DSCP.h:13:37: error: linux/netfilter/xt_dscp.h: No such file or directory out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_DSCP.c:45: error: 'XT_DSCP_MAX' undeclared here (not in a function) make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_DSCP.o] Error 1 make: *** Waiting for unfinished jobs.... Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
解决方法
将/usr/include/linux/netfilter/xt_dscp.h复制到 external/iptables/include/linux/netfilter/xt_dscp.h
问题15
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_MARK.c:4:37: error: linux/netfilter/xt_MARK.h: No such file or directory ...make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_MARK.o] Error 1 make: *** Waiting for unfinished jobs....
解决方法
将/usr/include/linux/netfilter/xt_MARK.h 复制到 external/iptables/include/linux/netfilter/xt_MARK.h
问题16
out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_TCPMSS.c:9:39: error: linux/netfilter/xt_TCPMSS.h: No such file or directory
解决方法
将/usr/include/linux/netfilter/xt_TCPMSS.h 复制到 external/iptables/include/linux/netfilter/xt_TCPMSS.h
问题17
out/target/product/generic/obj/STATIC_LIBRARIES/libext6_intermediates/libip6t_HL.c:9:42: error: linux/netfilter_ipv6/ip6t_HL.h: No such file or directory
解决方法
将/usr/include/linux/netfilter_ipv6/ip6t_HL.h 复制到 external/iptables/include/linux/netfilter_ipv6/ip6t_HL.h
问题18
bionic/libc/kernel/common/linux/netfilter_ipv4/ipt_DSCP.h:14:43: error: linux/netfilter_ipv4/ipt_dscp.h: No such file or directory
解决方法
把bionic/libc/kernel/common/linux/netfilter_ipv4下ipt_dscp.h和ipt_DSCP.h复制到/usr/include/linux/netfilter_ipv4内
问题19
make: *** [out/target/common/obj/APPS/android.core.tests.libcore.package.sun.no-core-tests-res_intermediates/noproguard.classes-with-local.dex] Killed make: *** Waiting for unfinished jobs.... make: *** [out/target/common/obj/APPS/android.core.tests.libcore.package.tests.no-core-tests-res_intermediates/noproguard.classes-with-local.dex] Killed Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/Ticker.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
解决方法
原因是内存不足,将make -j4改成make即可
编译sdk
make sdk
问题1
development/build/sdk.atree:229: couldn't locate source file: framework/layoutlib-tests.jar development/build/sdk.atree:230: couldn't locate source file: system/app/ConnectivityTest.apk development/build/sdk.atree:231: couldn't locate source file: system/app/GpsLocationTest.apk sdk/build/tools.atree:47: couldn't locate source file: usr/share/pc-bios/bios.bin sdk/build/tools.atree:48: couldn't locate source file: usr/share/pc-bios/vgabios-cirrus.bin sdk/build/tools.atree:146: couldn't locate source file: framework/ddmlib-tests.jar sdk/build/tools.atree:147: couldn't locate source file: framework/ninepatch-tests.jar sdk/build/tools.atree:148: couldn't locate source file: framework/common-tests.jar sdk/build/tools.atree:150: couldn't locate source file: framework/sdkuilib-tests.jar make: *** [out/host/linux-x86/sdk/android-sdk_eng.siuming_linux-x86.zip] Error 44
解决方法
source build/envsetup.shlunch sdk-eng
编译 sdk 时,先运行 lunch sdk-eng,不然编译会出错,例如:
development/build/sdk.atree:229: couldn't locate source file: framework/layoutlib-tests.jar
lunch 的自动补全中没有 sdk-eng,但实际上是支持的。
lunch sdk-eng 与 lunch full-eng 只有惟一的区别:一个的target是sdk,一个的是full。
把/out/host/linux-x86/framework目录下的layoutlib.jar、ddmlib.jar、ninepatch.jar、
common.jar、sdkuilib.jar分别复制一份,并重命名,命名的原则很简单,就是在原有的名字后面跟上-tests即可。
在模拟器中运行编译好的内核。
在启动模拟器之前,先设置模拟器的目录到环境变量$PATH中去
$ export PATH=$PATH:~/Android/out/host/linux-x86/bin
设置ANDROID_PRODUCT_OUT环境变量
$ export ANDROID_PRODUCT_OUT=~/Android/out/target/product/generic
在后台中指定内核文件启动模拟器
$ emulator -kernel ./kernel/common/arch/arm/boot/zImage &
用adb工具连接模拟器,查看内核版本信息,看看模拟器上跑的内核是不是我们刚才编译出来的内核
$ adb shell
这时候如果是第一次运行 adb shell命令,会看到以下输出,不用管它,再运行一次adb shell命令就可以了。
* daemon not running. start it now on port 5037 ** daemon started successfully *error: device offline
切换到proc目录
root[@android](https://my.oschina.net/asia):/ # cd procroot[@android](https://my.oschina.net/asia):/proc # cat versionLinux version 2.6.29-gb0d93fb-dirty (luo@ubuntu-11-04) (gcc version 4.4.3 (GCC) ) #1 Fri Jun 3 23:17:24 HKT 2011
从机器名luo@ubuntu-11-04和日期1 Fri Jun 3 23:17:24 HKT 2011可以看出,模拟器使用的内核即为刚刚编译出来的内核。