android源码编译错误总结

时间:2021-01-17 05:29:11

android源码编译及错误解决:

下载的源码,进入源码目录,执行make命令即可。

加快源码编译:make -jN,cpu有几个核N就填几

不过其中会有一些错误,下面是我编译中出现的错误,解决非常的简单;


编译源码中遇到的错误:

贴出来一个个解决:

绿色:表示找出问题

Yacc: aidl <= frameworks/base/tools/aidl/aidl_language_y.y
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


host C: adb <= system/core/adb/fdevent.c
host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb)
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1

原因:/usr/bin/ld: cannot find -lncurses
collect2: ld 返回 1 

首先到usr/lib/目录下寻找libncurses开头的文件
1.如果没有那就是缺少库文件
解决方法:

$ sudo apt-cache search ncurses-
有这样一个结果:
libncurses5-dev - developer's libraries and docs for ncurses

安装libncurses

解决方法:sudo apt-get install libncurses5-dev


Install: out/target/product/generic/system/lib/libttssynthproxy.so
Generating CSSPropertyNames.h <= CSSPropertyNames.in
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


解决完这些错误,就可以编译完android源码了。不过是要花费点时间的。

编译完成后,在你的源码目录下会有一个out文件,你可以查看是否编译成功了。