搞定!源码编译成功后的输出。
Generated: (out/target/product/generic/android-info.txt) Installed file list: out/target/product/generic/installed-files.txt Target system fs image: out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img Install system fs image: out/target/product/generic/system.img Target ram disk: out/target/product/generic/ramdisk.img Target userdata fs image: out/target/product/generic/userdata.img
工作超忙,总算有点空了。工作过程中不断的遇到一些困难,急切的需要补充一些必要的知识,但一般都很零散,一会要学这一会要学那,感觉很不好,于是便有了学习Android源码的打算。其实很早就看过老罗的博客,早有了学习源码的想法,但一直苦于没有Linux的知识基础,没敢开始去做,现在想想,还是先开始吧,反正源码的学习是个很漫长的过程,遇到需要的只是再去补充,这样学习起来也更有目的性。总之,趁着有点时间,先把学习的环境搭建起来再说。
先找些参考资料:
这个就是老罗写的,照这这些步骤去做就行。我想补充的或者说建议吧,就是下载源码的过程中会经常出现断开链接的现象,很烦人,所以推荐这个东西,在这篇博客的评论中@onrush提供的一个脚本很好用,拷贝到自己要放源码的目录下,例如我就是新建一个donwload的脚本文件,保存,再sudo chmod a+x download,然后执行,等待,以我这的网速来算,差不多十几二十个小时就搞定了,下面是他的代码,借花献佛了:D。
#!/bin/bash
command="repo sync"$command result=$? echo "result = "$result until [ $result -eq 0 ] do echo "retry" $command result=$? done
顺便贴下我下载源码的地址:repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
源码下载之后进行编译一般都会出现很多问题,几乎每台电脑上都会出现,所以建议在编译之前就执行一下所有解决办法中的命令。以下是我在编译源码的过程中出现的错误和在网络上找到的解决办法。
------------------Linux Mint------------------
Release:14(nadia)
Edition:MATE 64-bit
----------------Java------------------
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
ERROR & SOLUTION
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
错误:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o] Error 1
解决:
sudo apt-get install libc6-dev-i386
错误:
make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp] Error 1
解决:
sudo apt-get install g++-multilib
错误:
external/clearsilver/cgi/cgi.c:22: fatal error: zlib.h: No such file or directory
compilation terminated.
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libneo_cgi_intermediates/cgi.o] Error 1
解决:
sudo apt-get install zlib1g-dev
错误:
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] Error 1
解决:
sudo apt-get install lib32z1-dev
错误:
bison -d -o out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y
/bin/bash: bison: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error 127
解决:
sudo apt-get install bison
错误:
Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l
/bin/bash: flex: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127
解决:
sudo apt-get install flex
错误:
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
解决:
sudo apt-get install lib32ncurses5-dev
错误:
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:55: fatal error: X11/Xlib.h: No such file or directory
compilation terminated.
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/android/main-common.o] Error 1
解决:
sudo apt-get install libx11-dev
错误:
sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 96.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h] Error 25
make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h'
解决:
sudo apt-get install gperf
错误:
host StaticLib: libGLcommon (out/host/linux-x86/obj/STATIC_LIBRARIES/libGLcommon _intermediates/libGLcommon.a)
host SharedLib: libGLES_CM_translator (out/host/linux-x86/obj/lib/libGLES_CM_translator.so)
/usr/bin/ld: cannot find -lGLcollect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libGLES_CM_translator.so] Error 1
解决: sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1.2 /usr/lib/libGL.so
错误:
make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1
解决:版本过高,在配置环境的时候,gcc安装了高到版本,所以gcc版本太高导致,需要降低gcc版本
ubuntu 32bit系统下安装gcc 4.4的最好方法是仅用以下两条命令,不需要其它命令,否则编译时可能会出错。
sudo apt-get install gcc-4.4
sudo apt-get install g++-4.4
操作过程见:
gcc降级:
sudo rm -rf /usr/bin/gcc
sudo ln -s /usr/bin/gcc-4.4 /usr/bin/gcc
g++降级
sudo rm -rf /usr/bin/g++
sudo ln -s /usr/bin/g++-4.4 /usr/bin/g++
错误:
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/AssetManager.o] Error 1
或者 make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/AssetManager.o] Error 1
解决:在 frameworks/base/libs/utils/Android.mk
在第60行后面增加-fpermissive: (这里不一定是第60行,我的就不是)
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive
错误:
make: *** [out/host/linux-x86/obj/EXECUTABLES/grxmlcompile_intermediates/grxmlcompile.o] Error 1
或者 make: *** [out/host/linux-x86/obj/EXECUTABLES/grxmlcompile_intermediates/grxmlcompile.o] Error 1
解决:cd your_source_directory/external/srec
复制拷贝下面的命令到终端:
patch -p1 < 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
rm -f 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
错误:
development/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp:22:
make:
解决:sudo
错误:
host SharedLib: libOpenglRender (out/host/linux-x86/obj/lib/libOpenglRender.so)
/usr/bin/ld: cannot find -lX11
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libOpenglRender.so] Error 1
解决: sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
编译的时候没想到要把所有的错误都记下来,我还记得的就是这些了,以上所有解决方法来自以下链接:http://www.cnblogs.com/xilinch/archive/2013/04/02/2996359.html
http://blog.sina.com.cn/s/blog_ab85e99501018r6z.html
http://blog.csdn.net/z_guijin/article/details/7720841
http://www.cnblogs.com/jvlstudio/articles/2046562.html